123456789_123456789_123456789_123456789_123456789_

Class: Ripper::Lexer::Elem

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Struct
Instance Chain:
self, Struct
Inherits: Struct
Defined in: ext/ripper/lib/ripper/lexer.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(pos, event, tok, state, message = nil) ⇒ Elem

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 64

def initialize(pos, event, tok, state, message = nil)
  super(pos, event, tok, State.new(state), message)
end

Instance Attribute Details

#event (rw)

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 63

Elem = Struct.new(:pos, :event, :tok, :state, :message)

#message (rw)

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 63

Elem = Struct.new(:pos, :event, :tok, :state, :message)

#pos (rw)

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 63

Elem = Struct.new(:pos, :event, :tok, :state, :message)

#state (rw)

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 63

Elem = Struct.new(:pos, :event, :tok, :state, :message)

#tok (rw)

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 63

Elem = Struct.new(:pos, :event, :tok, :state, :message)

Instance Method Details

#inspect

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 68

def inspect
  "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if message}#{message}>"
end

#pretty_print(q)

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 72

def pretty_print(q)
  q.group(2, "#<#{self.class}:", ">") {
    q.breakable
    q.text("#{event}@#{pos[0]}:#{pos[1]}")
    q.breakable
    q.text(state)
    q.breakable
    q.text("token: ")
    tok.pretty_print(q)
    if message
      q.breakable
      q.text("message: ")
      q.text(message)
    end
  }
end

#to_a

[ GitHub ]

  
# File 'ext/ripper/lib/ripper/lexer.rb', line 89

def to_a
  a = super
  a.pop unless a.last
  a
end