Class: Caps::Tokenizer::Location
- Inherits:
-
Object
- Object
- Caps::Tokenizer::Location
- Defined in:
- lib/caps/tokenizer/location.rb
Instance Attribute Summary collapse
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(parser) ⇒ Location
constructor
A new instance of Location.
- #push_node(type, **opts) ⇒ Object
Constructor Details
#initialize(parser) ⇒ Location
Returns a new instance of Location.
8 9 10 11 |
# File 'lib/caps/tokenizer/location.rb', line 8 def initialize(parser) @parser = parser @start = parser.pos end |
Instance Attribute Details
#start ⇒ Object (readonly)
Returns the value of attribute start.
6 7 8 |
# File 'lib/caps/tokenizer/location.rb', line 6 def start @start end |
Instance Method Details
#finish ⇒ Object
17 18 19 20 21 22 |
# File 'lib/caps/tokenizer/location.rb', line 17 def finish { start: @start, end: @parser.pos } end |
#push_node(type, **opts) ⇒ Object
13 14 15 |
# File 'lib/caps/tokenizer/location.rb', line 13 def push_node(type, **opts) @parser.push_node(type, **opts.merge({ position: finish })) end |