Class: Ruby::If

Direct Known Subclasses

Unless

Instance Attribute Summary

Attributes included from Node::Composite

#parent

Instance Method Summary collapse

Methods included from Conversions::Statements

#to_block, #to_chained_block, #to_named_block, #to_program

Methods inherited from List

#method_missing

Methods included from Alternation::List

#<<, #[]=, #pop

Methods included from Conversions::List

#to_array

Methods inherited from Aggregate

#position, #position=, #prolog, #prolog=, #to_ruby

Methods inherited from Node

#<=>, #all_nodes, #column, #length, #row

Methods included from Conversions

included, #to_node

Methods included from Node::Traversal

#has_token?, #has_type?, #has_value?, #is_instance_of?, #left_of?, #matches?, #position?, #right_of?, #select

Methods included from Node::Source

#context, #filename, #line, #lines, #src

Methods included from Node::Composite

included, #root, #root?

Constructor Details

#initialize(identifier, expression, statements = nil, ldelim = nil, rdelim = nil, else_block = nil) ⇒ If

Returns a new instance of If.



7
8
9
10
# File 'lib/ruby/if.rb', line 7

def initialize(identifier, expression, statements = nil, ldelim = nil, rdelim = nil, else_block = nil)
  self.expression = expression
  super(identifier, [else_block], statements, nil, ldelim, rdelim)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ruby::List

Instance Method Details

#nodesObject



12
13
14
# File 'lib/ruby/if.rb', line 12

def nodes
  [identifier, expression, ldelim, elements, blocks, rdelim].flatten.compact
end