Class: Language::Atom::Then
- Inherits:
-
Language::Atom
- Object
- Language::Atom
- Language::Atom::Then
- Defined in:
- lib/language/atom/then.rb
Instance Method Summary collapse
-
#initialize(parent:, block:) ⇒ Then
constructor
A new instance of Then.
- #parse(parser) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Language::Atom
#<<, #>>, #absent, #aka, #any, #ignore, #inspect, #maybe, #repeat, #str, #then, #|
Constructor Details
#initialize(parent:, block:) ⇒ Then
Returns a new instance of Then.
6 7 8 9 |
# File 'lib/language/atom/then.rb', line 6 def initialize(parent:, block:) @parent = parent @block = block end |
Instance Method Details
#parse(parser) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/language/atom/then.rb', line 11 def parse(parser) @parent.parse(parser) if parser.output.nil? parser.buffer = @block.call(parser.buffer) else parser.output = Output.from_raw(@block.call(parser.output.to_raw)) end end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/language/atom/then.rb', line 21 def to_s "(#{@parent}).then {}" end |