Class: Eqn::Function::RoundBase

Inherits:
EqnNode
  • Object
show all
Defined in:
lib/eqn/function.rb

Overview

Base node class for round functions.

Direct Known Subclasses

Round, RoundDown, RoundUp

Instance Method Summary collapse

Methods inherited from EqnNode

#clean_tree!, #term?

Instance Method Details

#value(vars) ⇒ Object

Raises:



16
17
18
19
20
21
22
23
24
25
# File 'lib/eqn/function.rb', line 16

def value(vars)
  value = elements.shift.value(vars)
  raise ZeroDivisionError if value.is_a?(Float) && (value.abs == Float::INFINITY || value.nan?)

  if term?
    value.send(self.class::ROUND_METHOD)
  else
    round_to_precision(vars, value)
  end
end