class
Money::Currency
- Money::Currency
- Reference
- Object
Overview
Represents a specific currency unit.
See ISO 4217.
Included Modules
- Comparable(Money::Currency)
- JSON::Serializable
Extended Modules
Defined in:
money/currency.crmoney/currency/enumeration.cr
money/currency/exchange.cr
money/currency/exchange/single_currency.cr
money/currency/json.cr
money/currency/loader.cr
money/currency/rate.cr
money/currency/rate_provider.cr
money/currency/rate_provider/abstract_api.cr
money/currency/rate_provider/coinlayer.cr
money/currency/rate_provider/compound.cr
money/currency/rate_provider/currency_api.cr
money/currency/rate_provider/currency_beacon.cr
money/currency/rate_provider/currency_layer.cr
money/currency/rate_provider/ecb.cr
money/currency/rate_provider/exchange_rate_api.cr
money/currency/rate_provider/fixer.cr
money/currency/rate_provider/float_rates.cr
money/currency/rate_provider/freecurrency_api.cr
money/currency/rate_provider/fx_feed.cr
money/currency/rate_provider/fx_rates_api.cr
money/currency/rate_provider/http.cr
money/currency/rate_provider/metalprice_api.cr
money/currency/rate_provider/money_morph.cr
money/currency/rate_provider/null.cr
money/currency/rate_provider/open_exchange_rates.cr
money/currency/rate_provider/uni_rate_api.cr
money/currency/rate_store.cr
money/currency/rate_store/file.cr
money/currency/rate_store/memory.cr
money/currency/type.cr
Constructors
- .new(pull : JSON::PullParser)
- .new(*, type : Money::Currency::Type | Nil = nil, priority : Int32 | Nil = nil, iso_numeric : Int32 | Nil = nil, code : String, name : Nil | String = nil, symbol : Nil | String = nil, disambiguate_symbol : Nil | String = nil, alternate_symbols : Nil | Array(String) = nil, subunit : Nil | String = nil, subunit_to_unit : UInt64, symbol_first : Bool | Nil = nil, decimal_mark : Nil | String = nil, thousands_separator : Nil | String = nil, smallest_denomination : Int32 | Nil = nil)
-
.register(currency : Currency) : Currency
Registers a new currency.
Class Method Summary
-
.crypto : Array(Currency)
Returns an array of currencies of type
Crypto
. -
.fiat : Array(Currency)
Returns an array of currencies of type
Fiat
. -
.metal : Array(Currency)
Returns an array of currencies of type
Metal
. -
.registry : Hash(String, Currency)
List of known currencies.
-
.reset! : Nil
Resets all registered currencies to their defaults.
-
.unregister(currency : String | Symbol | Currency) : Currency | Nil
Unregisters a currency.
Instance Method Summary
- #<=>(other : Currency) : Int32
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#alternate_symbols : Array(String) | Nil
Alternate symbols.
-
#cents_based? : Bool
Returns
true
if a subunit is cents-based. -
#code : String
Currency code.
-
#crypto? : Bool
Returns
true
if the currency#type
isCrypto
, otherwisefalse
. -
#decimal_mark : String | Nil
Decimal mark.
-
#decimal_places : Int32
Alias of
#exponent
. -
#disambiguate_symbol : String | Nil
Disambiguation symbol.
-
#exponent : Int32
Returns the relation between subunit and unit as a base 10 exponent.
-
#fiat? : Bool
Returns
true
if the currency#type
isFiat
, otherwisefalse
. -
#hash(hasher)
See
Object#hash(hasher)
-
#id : String
Currency ID (lower-cased
#code
). -
#iso? : Bool
Returns
true
if iso currency. -
#iso_numeric : Int32 | Nil
ISO 4217 numeric code.
-
#metal? : Bool
Returns
true
if the currency#type
isMetal
, otherwisefalse
. -
#name : String | Nil
Currency name.
-
#priority : Int32 | Nil
Currency priority (used for sorting).
-
#smallest_denomination : Int32 | Nil
Smallest denomination.
-
#subunit : String | Nil
Currency subunit.
-
#subunit_to_unit : UInt64
Subunit to unit value.
-
#symbol : String | Nil
Currency symbol.
-
#symbol_first? : Bool | Nil
Should the symbol be placed before the amount?
-
#thousands_separator : String | Nil
Thousands separator.
-
#to_s(io : IO) : Nil
Appends a string representation corresponding to the
#code
property to the given io. -
#type : Type | Nil
Currency type.
Constructor Detail
Class Method Detail
Unregisters a currency.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Returns true
if a subunit is cents-based.
Money::Currency.find(:usd).cents_based? # => true
Money::Currency.find(:btc).cents_based? # => false
Returns the relation between subunit and unit as a base 10 exponent.
Money::Currency.find(:usd).exponent # => 2
Money::Currency.find(:btc).exponent # => 8
NOTE MGA and MRU are exceptions and are rounded to 1.
See Active_codes.
Returns true
if iso currency.
Money::Currency.find(:usd).iso? # => true
Money::Currency.find(:btc).iso? # => false
See also #iso_numeric
.