Class: IfNode

Inherits:
Node
  • Object
show all
Defined in:
lib/nodes/stmtnodes.rb

Overview

If Statement Nodes

Instance Attribute Summary collapse

Attributes inherited from Node

#value

Instance Method Summary collapse

Constructor Details

#initialize(argument, node) ⇒ IfNode

Returns a new instance of IfNode.



162
163
164
# File 'lib/nodes/stmtnodes.rb', line 162

def initialize(argument, node)
  @argument, @node = argument, node
end

Instance Attribute Details

#argumentObject

Returns the value of attribute argument.



160
161
162
# File 'lib/nodes/stmtnodes.rb', line 160

def argument
  @argument
end

Instance Method Details

#create_tree_entryObject



170
171
172
173
174
# File 'lib/nodes/stmtnodes.rb', line 170

def create_tree_entry
  result = set_up_scope_header
  result += "If statement #{@argument} is used"
  TREE_ARRAY << result unless TREE_ARRAY[-1] == result
end

#evaluateObject



176
177
178
179
180
# File 'lib/nodes/stmtnodes.rb', line 176

def evaluate
  @value = @node.evaluate
  create_tree_entry if PRINT_TREE_FLAG
  @value
end

#to_sObject



166
167
168
# File 'lib/nodes/stmtnodes.rb', line 166

def to_s
  "If #{argument}"
end