Class: Language::Atom::Then

Inherits:
Language::Atom show all
Defined in:
lib/language/atom.rb

Instance Method Summary collapse

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.



16
17
18
19
# File 'lib/language/atom.rb', line 16

def initialize(parent:, block:)
  @parent = parent
  @block = block
end

Instance Method Details

#parse(parser) ⇒ Object



21
22
23
24
# File 'lib/language/atom.rb', line 21

def parse(parser)
  @parent.parse(parser)
  parser.output = Output.from_raw(@block.call(parser.output.to_raw))
end

#to_sObject



26
27
28
# File 'lib/language/atom.rb', line 26

def to_s
  "(#{@parent}).then {}"
end