Class: Money

Inherits:
Object show all
Includes:
Conversion::Accessors
Defined in:
lib/conversion_test.rb

Overview


Constant Summary

Constants included from Conversion::Accessors

Conversion::Accessors::ACCESSOR_OPTIONS

Instance Method Summary collapse

Methods included from Conversion::Accessors

append_features

Constructor Details

#initialize(amount, currency = :euro) ⇒ Money

Returns a new instance of Money.



29
30
31
32
# File 'lib/conversion_test.rb', line 29

def initialize(amount, currency=:euro)
  self.amount = amount
  self.currency = currency
end

Instance Method Details

#==(other) ⇒ Object



34
# File 'lib/conversion_test.rb', line 34

def ==(other) currency == other.currency && (amount - other.amount).abs/[amount.abs, other.amount.abs].max < 1e-10 end

#to_fObject



33
# File 'lib/conversion_test.rb', line 33

def to_f() amount.to_f end

#to_sObject



35
# File 'lib/conversion_test.rb', line 35

def to_s() amount.to_s end