Class: Ripper::Lexer::Elem
- Inherits:
-
Struct
- Object
- Struct
- Ripper::Lexer::Elem
- Defined in:
- lib/ripper/lexer.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
Returns the value of attribute event.
-
#message ⇒ Object
Returns the value of attribute message.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#state ⇒ Object
Returns the value of attribute state.
-
#tok ⇒ Object
Returns the value of attribute tok.
Instance Method Summary collapse
-
#initialize(pos, event, tok, state, message = nil) ⇒ Elem
constructor
A new instance of Elem.
- #inspect ⇒ Object
- #pretty_print(q) ⇒ Object
- #to_a ⇒ Object
Constructor Details
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event
63 64 65 |
# File 'lib/ripper/lexer.rb', line 63 def event @event end |
#message ⇒ Object
Returns the value of attribute message
63 64 65 |
# File 'lib/ripper/lexer.rb', line 63 def @message end |
#pos ⇒ Object
Returns the value of attribute pos
63 64 65 |
# File 'lib/ripper/lexer.rb', line 63 def pos @pos end |
#state ⇒ Object
Returns the value of attribute state
63 64 65 |
# File 'lib/ripper/lexer.rb', line 63 def state @state end |
#tok ⇒ Object
Returns the value of attribute tok
63 64 65 |
# File 'lib/ripper/lexer.rb', line 63 def tok @tok end |
Instance Method Details
#inspect ⇒ Object
68 69 70 |
# File 'lib/ripper/lexer.rb', line 68 def inspect "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if }#{}>" end |
#pretty_print(q) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File '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 q.breakable q.text("message: ") q.text() end } end |
#to_a ⇒ Object
89 90 91 92 93 |
# File 'lib/ripper/lexer.rb', line 89 def to_a a = super a.pop unless a.last a end |