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
70 71 72 |
# File 'lib/ripper/lexer.rb', line 70 def event @event end |
#message ⇒ Object
Returns the value of attribute message
70 71 72 |
# File 'lib/ripper/lexer.rb', line 70 def @message end |
#pos ⇒ Object
Returns the value of attribute pos
70 71 72 |
# File 'lib/ripper/lexer.rb', line 70 def pos @pos end |
#state ⇒ Object
Returns the value of attribute state
70 71 72 |
# File 'lib/ripper/lexer.rb', line 70 def state @state end |
#tok ⇒ Object
Returns the value of attribute tok
70 71 72 |
# File 'lib/ripper/lexer.rb', line 70 def tok @tok end |
Instance Method Details
#inspect ⇒ Object
75 76 77 |
# File 'lib/ripper/lexer.rb', line 75 def inspect "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if }#{}>" end |
#pretty_print(q) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ripper/lexer.rb', line 79 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
96 97 98 99 100 |
# File 'lib/ripper/lexer.rb', line 96 def to_a a = super a.pop unless a.last a end |