Class: Prism::Translation::Ripper::Lexer::Elem
- Inherits:
-
Object
- Object
- Prism::Translation::Ripper::Lexer::Elem
- Defined in:
- lib/prism/translation/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
- #[](index) ⇒ Object
-
#initialize(pos, event, tok, state, message = nil) ⇒ Elem
constructor
A new instance of Elem.
- #inspect ⇒ Object (also: #to_s)
- #pretty_print(q) ⇒ Object
- #to_a ⇒ Object
Constructor Details
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event.
51 52 53 |
# File 'lib/prism/translation/ripper/lexer.rb', line 51 def event @event end |
#message ⇒ Object
Returns the value of attribute message.
51 52 53 |
# File 'lib/prism/translation/ripper/lexer.rb', line 51 def @message end |
#pos ⇒ Object
Returns the value of attribute pos.
51 52 53 |
# File 'lib/prism/translation/ripper/lexer.rb', line 51 def pos @pos end |
#state ⇒ Object
Returns the value of attribute state.
51 52 53 |
# File 'lib/prism/translation/ripper/lexer.rb', line 51 def state @state end |
#tok ⇒ Object
Returns the value of attribute tok.
51 52 53 |
# File 'lib/prism/translation/ripper/lexer.rb', line 51 def tok @tok end |
Instance Method Details
#[](index) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/prism/translation/ripper/lexer.rb', line 61 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 ⇒ Object Also known as: to_s
78 79 80 |
# File 'lib/prism/translation/ripper/lexer.rb', line 78 def inspect "#<#{self.class}: #{event}@#{pos[0]}:#{pos[1]}:#{state}: #{tok.inspect}#{": " if }#{}>" end |
#pretty_print(q) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/prism/translation/ripper/lexer.rb', line 84 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 q.breakable q.text("message: ") q.text() end } end |
#to_a ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/prism/translation/ripper/lexer.rb', line 101 def to_a if @message [@pos, @event, @tok, @state, @message] else [@pos, @event, @tok, @state] end end |