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.



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

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

Instance Method Details

#==(other) ⇒ Object



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

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

#to_fObject



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

def to_f() amount.to_f end

#to_sObject



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

def to_s() amount.to_s end