Class: CommerceUnits::Simplifier

Inherits:
Object
  • Object
show all
Defined in:
lib/commerce_units/simplifier.rb

Defined Under Namespace

Classes: NotComparable

Instance Method Summary collapse

Constructor Details

#initialize(numerator: [], denominator: []) ⇒ Simplifier

Returns a new instance of Simplifier.



3
4
5
6
# File 'lib/commerce_units/simplifier.rb', line 3

def initialize(numerator: [], denominator: [])
  @original_top = numerator.sort
  @original_bot = denominator.sort
end

Instance Method Details

#denominatorObject



12
13
14
# File 'lib/commerce_units/simplifier.rb', line 12

def denominator
  @denominator ||= _reduced_denominator_from top: @original_top, bot: @original_bot
end

#numeratorObject



8
9
10
# File 'lib/commerce_units/simplifier.rb', line 8

def numerator
  @numerator ||= _reduced_numerator_from top: @original_top, bot: @original_bot
end