Class: Code::Node::Decimal
- Inherits:
-
Code::Node
- Object
- Code::Node
- Code::Node::Decimal
- Defined in:
- lib/code/node/decimal.rb
Instance Method Summary collapse
- #evaluate(**args) ⇒ Object
-
#initialize(parsed) ⇒ Decimal
constructor
A new instance of Decimal.
Methods inherited from Code::Node
Constructor Details
#initialize(parsed) ⇒ Decimal
Returns a new instance of Decimal.
6 7 8 9 10 11 12 13 14 |
# File 'lib/code/node/decimal.rb', line 6 def initialize(parsed) return if parsed.blank? @decimal = parsed.delete(:decimal).presence return unless parsed.key?(:exponent) @exponent = Statement.new(parsed.delete(:exponent).presence) end |
Instance Method Details
#evaluate(**args) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/code/node/decimal.rb', line 16 def evaluate(**args) if @exponent && @decimal Object::Decimal.new(@decimal, @exponent.evaluate(**args)) elsif @decimal Object::Decimal.new(@decimal) else Object::Nothing.new end end |