Class: KansujiToNumber::Layer1ExpressionNode

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



14
15
16
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 14

def left
  @left
end

#rightObject

Returns the value of attribute right

Returns:

  • (Object)

    the current value of right



14
15
16
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 14

def right
  @right
end

#unitObject

Returns the value of attribute unit

Returns:

  • (Object)

    the current value of unit



14
15
16
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 14

def unit
  @unit
end

Instance Method Details

#evalObject



15
16
17
18
19
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 15

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