Class: Rubasteme::AST::DoNode

Inherits:
ListNode show all
Defined in:
lib/rubasteme/ast/branch_node.rb

Instance Method Summary collapse

Methods inherited from ListNode

#elements, #empty?, #first, #rest

Methods inherited from BranchNode

#<<, #[], #[]=, #each, #size, #to_a

Methods inherited from Node

#to_a, #to_s, #type

Constructor Details

#initialize(_ = nil) ⇒ DoNode

Returns a new instance of DoNode.



583
584
585
586
# File 'lib/rubasteme/ast/branch_node.rb', line 583

def initialize(_ = nil)
  # @nodes = [<iteration bindings>, <test and do result>, <command>, ...]
  super(2, _)
end

Instance Method Details

#add_command(node) ⇒ Object



608
609
610
# File 'lib/rubasteme/ast/branch_node.rb', line 608

def add_command(node)
  @nodes << node
end

#commandsObject



604
605
606
# File 'lib/rubasteme/ast/branch_node.rb', line 604

def commands
  @nodes[2..-1]
end

#iteration_bindingsObject



588
589
590
# File 'lib/rubasteme/ast/branch_node.rb', line 588

def iteration_bindings
  @nodes[0]
end

#iteration_bindings=(node) ⇒ Object



592
593
594
# File 'lib/rubasteme/ast/branch_node.rb', line 592

def iteration_bindings=(node)
  @nodes[0] = node
end

#test_and_do_resultObject



596
597
598
# File 'lib/rubasteme/ast/branch_node.rb', line 596

def test_and_do_result
  @nodes[1]
end

#test_and_do_result=(node) ⇒ Object



600
601
602
# File 'lib/rubasteme/ast/branch_node.rb', line 600

def test_and_do_result=(node)
  @nodes[1] = node
end