Class: Zaid::Nodes::IfNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/zaid/nodes/if_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



5
6
7
# File 'lib/zaid/nodes/if_node.rb', line 5

def body
  @body
end

#conditionObject

Returns the value of attribute condition

Returns:

  • (Object)

    the current value of condition



5
6
7
# File 'lib/zaid/nodes/if_node.rb', line 5

def condition
  @condition
end

#else_bodyObject

Returns the value of attribute else_body

Returns:

  • (Object)

    the current value of else_body



5
6
7
# File 'lib/zaid/nodes/if_node.rb', line 5

def else_body
  @else_body
end

Instance Method Details

#eval(context) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/zaid/nodes/if_node.rb', line 6

def eval(context)
  if condition.eval(context).ruby_value
    body.eval(context)
  elsif else_body
    else_body.eval(context)
  else
    Constants['مجهول']
  end
end