Class: KansujiToNumber::Layer2ExpressionNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/kansuji_to_number/kansuji_nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#leftObject

Returns the value of attribute left

Returns:

  • (Object)

    the current value of left



22
23
24
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 22

def left
  @left
end

#rightObject

Returns the value of attribute right

Returns:

  • (Object)

    the current value of right



22
23
24
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 22

def right
  @right
end

#unitObject

Returns the value of attribute unit

Returns:

  • (Object)

    the current value of unit



22
23
24
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 22

def unit
  @unit
end

Instance Method Details

#evalObject



23
24
25
26
27
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 23

def eval
    l = left ? left.eval : 1
    r = right ? right.eval : 0
    l * unit + r
end