class Money::Currency

Attributes

decimal_mark[R]
disambiguate_symbol[R]
iso_code[R]
iso_numeric[R]
minor_units[R]
name[R]
smallest_denomination[R]
subunit_symbol[R]
subunit_to_unit[R]
symbol[R]
to_s[R]

Public Class Methods

currencies() click to toggle source
# File lib/money/currency.rb, line 25
def currencies
  @@currencies ||= Loader.load_currencies
end
find(currency_iso) click to toggle source
# File lib/money/currency.rb, line 19
def find(currency_iso)
  new(currency_iso)
rescue UnknownCurrency
  nil
end
find!(currency_iso)
Alias for: new
new(currency_iso) click to toggle source
Calls superclass method
# File lib/money/currency.rb, line 12
def new(currency_iso)
  raise UnknownCurrency, "Currency can't be blank" if currency_iso.nil? || currency_iso.to_s.empty?
  iso = currency_iso.to_s.downcase
  @@loaded_currencies[iso] || @@mutex.synchronize { @@loaded_currencies[iso] = super(iso) }
end
Also aliased as: find!
new(currency_iso) click to toggle source
# File lib/money/currency.rb, line 33
def initialize(currency_iso)
  data = self.class.currencies[currency_iso]
  raise UnknownCurrency, "Invalid iso4217 currency '#{currency_iso}'" unless data
  @symbol                = data['symbol']
  @disambiguate_symbol   = data['disambiguate_symbol'] || data['symbol']
  @subunit_symbol        = data['subunit_symbol']
  @iso_code              = data['iso_code']
  @iso_numeric           = data['iso_numeric']
  @name                  = data['name']
  @smallest_denomination = data['smallest_denomination']
  @subunit_to_unit       = data['subunit_to_unit']
  @decimal_mark          = data['decimal_mark']
  @minor_units           = subunit_to_unit == 0 ? 0 : Math.log(subunit_to_unit, 10).round.to_i
  freeze
end

Public Instance Methods

==(other)
Alias for: eql?
compatible?(other) click to toggle source
# File lib/money/currency.rb, line 57
def compatible?(other)
  other.is_a?(NullCurrency) || eql?(other)
end
eql?(other) click to toggle source
# File lib/money/currency.rb, line 49
def eql?(other)
  self.class == other.class && iso_code == other.iso_code
end
Also aliased as: ==
hash() click to toggle source
# File lib/money/currency.rb, line 53
def hash
  [ self.class, iso_code ].hash
end