Class: UnitManager::Unit

Inherits:
Object
  • Object
show all
Includes:
CalculationHelper
Defined in:
lib/unit_manager/unit.rb

Constant Summary collapse

MAX_EQUATION_SIZE =
999
INVALID_EQUATION_SYMBOL =
["(", ")", "!", "&", "%"]

Instance Method Summary collapse

Methods included from CalculationHelper

#addition, #calculation_equation, #division, #multiplication, #subtraction

Constructor Details

#initialize(key:, name:, equation:) ⇒ Unit

Returns a new instance of Unit.



10
11
12
13
14
# File 'lib/unit_manager/unit.rb', line 10

def initialize(key:, name:, equation:)
  @key = key
  @name = name
  @equation = equation
end

Instance Method Details

#unit(value) ⇒ Object



16
17
18
# File 'lib/unit_manager/unit.rb', line 16

def unit(value)
  "#{derive_value(value)}#{@name}"
end