lib/code/node/base_10_decimal.rb in template-ruby-0.1.0 vs lib/code/node/base_10_decimal.rb in template-ruby-0.2.0

- old
+ new

@@ -1,23 +1,28 @@ class Code class Node - class Base10Decimal + class Base10Decimal < Node def initialize(number) @sign = number[:sign] @whole = number.fetch(:whole) @decimal = number.fetch(:decimal) if number.key?(:exponent) @exponent = ::Code::Node::Base10Number.new(number[:exponent]) end end - def evaluate(context) - @exponent = @exponent.evaluate(context) if @exponent - ::Code::Object::Decimal.new( - "#{sign}#{whole}.#{decimal}", - exponent: @exponent - ) + def evaluate(**args) + if @exponent + exponent = @exponent.evaluate(**args) + + ::Code::Object::Decimal.new( + "#{sign}#{whole}.#{decimal}", + exponent: exponent, + ) + else + ::Code::Object::Decimal.new("#{sign}#{whole}.#{decimal}") + end end private attr_reader :sign, :whole, :decimal