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



8
9
10
11
# 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



13
14
15
16
17
18
19
# File 'lib/query/node/base_10.rb', line 13

def evaluate(**args)
  if exponent
    whole.to_i * 10 ** exponent.evaluate(**args)
  else
    whole.to_i
  end
end