Class: Rubasteme::AST::CaseNode

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) ⇒ CaseNode

Returns a new instance of CaseNode.



364
365
366
367
# File 'lib/rubasteme/ast/branch_node.rb', line 364

def initialize(_ = nil)
  # @nodes = [<expression>, <case caluse>, ... <else clause>]
  super(1, _)
end

Instance Method Details

#add_clause(node) ⇒ Object



381
382
383
# File 'lib/rubasteme/ast/branch_node.rb', line 381

def add_clause(node)
  @nodes << node
end

#case_clausesObject



377
378
379
# File 'lib/rubasteme/ast/branch_node.rb', line 377

def case_clauses
  @nodes[1..-1]
end

#expressionObject



369
370
371
# File 'lib/rubasteme/ast/branch_node.rb', line 369

def expression
  @nodes[0]
end

#expression=(node) ⇒ Object



373
374
375
# File 'lib/rubasteme/ast/branch_node.rb', line 373

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