In Files

  • ripper/lib/ripper/lexer.rb

Class/Module Index [+]

Quicksearch

Ripper::Lexer::Elem

Attributes

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

Public Class Methods

new(pos, event, tok, state, message = nil) click to toggle source
 
               # File ripper/lib/ripper/lexer.rb, line 89
def initialize(pos, event, tok, state, message = nil)
  @pos = pos
  @event = event
  @tok = tok
  @state = State.new(state)
  @message = message
end
            

Public Instance Methods

[](index) click to toggle source
 
               # File ripper/lib/ripper/lexer.rb, line 97
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() click to toggle source
 
               # File ripper/lib/ripper/lexer.rb, line 114
def inspect
  "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if message}#{message}>"
end
            
Also aliased as: to_s
pretty_print(q) click to toggle source
 
               # File ripper/lib/ripper/lexer.rb, line 120
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() click to toggle source
 
               # File ripper/lib/ripper/lexer.rb, line 137
def to_a
  if @message
    [@pos, @event, @tok, @state, @message]
  else
    [@pos, @event, @tok, @state]
  end
end
            
to_s() click to toggle source
Alias for: inspect
There is an updated format of the API docs for this version here.