Class: Query::Node::Base10

Inherits:
Query::Node show all
Defined in:
lib/query/node/base_10.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#exponentObject

Returns the value of attribute exponent.



6
7
8
# File 'lib/query/node/base_10.rb', line 6

def exponent
  @exponent
end

#wholeObject

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