Class: KansujiToNumber::PureExpressionNode
- Inherits:
-
Struct
- Object
- Struct
- KansujiToNumber::PureExpressionNode
- Defined in:
- lib/kansuji_to_number/kansuji_nodes.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args
2 3 4 |
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 2 def args @args end |
Instance Method Details
#eval ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/kansuji_to_number/kansuji_nodes.rb', line 3 def eval figure = 1 sum = args.reverse.inject(0) {|result, item| result = result + item * figure figure *= 10 result } sum.to_i end |