Class: Query::Node::Base10
- Inherits:
-
Query::Node
- Object
- Query::Node
- Query::Node::Base10
- Defined in:
- lib/query/node/base_10.rb
Instance Attribute Summary collapse
-
#exponent ⇒ Object
Returns the value of attribute exponent.
-
#whole ⇒ Object
Returns the value of attribute whole.
Instance Method Summary collapse
- #evaluate(**args) ⇒ Object
-
#initialize(parsed) ⇒ Base10
constructor
A new instance of Base10.
Constructor Details
#initialize(parsed) ⇒ Base10
Returns a new instance of Base10.
8 9 10 11 12 |
# File 'lib/query/node/base_10.rb', line 8 def initialize(parsed) self.whole = parsed.delete(:whole) self.exponent = Node::Value.new(parsed.delete(:exponent)) if parsed.key?(:exponent) end |
Instance Attribute Details
#exponent ⇒ Object
Returns the value of attribute exponent.
6 7 8 |
# File 'lib/query/node/base_10.rb', line 6 def exponent @exponent end |
#whole ⇒ Object
Returns the value of attribute whole.
6 7 8 |
# File 'lib/query/node/base_10.rb', line 6 def whole @whole end |
Instance Method Details
#evaluate(**args) ⇒ Object
14 15 16 |
# File 'lib/query/node/base_10.rb', line 14 def evaluate(**args) exponent ? whole.to_i * 10**exponent.evaluate(**args) : whole.to_i end |