類別 Ripper::Lexer::Elem

屬性

event[RW]
message[RW]
pos[RW]
state[RW]
tok[RW]

公開類別方法

new(pos, event, tok, state, message = nil) 按一下以切換來源
# File ext/ripper/lib/ripper/lexer.rb, line 90
def initialize(pos, event, tok, state, message = nil)
  @pos = pos
  @event = event
  @tok = tok
  @state = State.new(state)
  @message = message
end

公開實例方法

[](index) 按一下以切換來源
# File ext/ripper/lib/ripper/lexer.rb, line 98
def [](index)
  case index
  when 0, :pos
    @pos
  when 1, :event
    @event
  when 2, :tok
    @tok
  when 3, :state
    @state
  when 4, :message
    @message
  else
    nil
  end
end
inspect() 按一下以切換來源
# File ext/ripper/lib/ripper/lexer.rb, line 115
def inspect
  "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if message}#{message}>"
end
別名為:to_s
pretty_print(q) 按一下以切換來源
# File ext/ripper/lib/ripper/lexer.rb, line 121
def pretty_print(q)
  q.group(2, "#<#{self.class}:", ">") {
    q.breakable
    q.text("#{event}@#{pos[0]}:#{pos[1]}")
    q.breakable
    state.pretty_print(q)
    q.breakable
    q.text("token: ")
    tok.pretty_print(q)
    if message
      q.breakable
      q.text("message: ")
      q.text(message)
    end
  }
end
to_a() 按一下以切換來源
# File ext/ripper/lib/ripper/lexer.rb, line 138
def to_a
  if @message
    [@pos, @event, @tok, @state, @message]
  else
    [@pos, @event, @tok, @state]
  end
end
to_s()
別名為:inspect