class

Money::Currency

Inherits JSON::Serializable / Comparable / Comparable / Reference / Object

Represents a specific currency unit.

See ISO 4217.

Constructors

new(pull : JSON::PullParser)
Source
new(*, priority : Int32 | Nil = nil, iso_numeric : UInt32 | 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, html_entity : Nil | String = nil, decimal_mark : Nil | String = nil, thousands_separator : Nil | String = nil, smallest_denomination : UInt32 | Nil = nil)
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source
wrap(value : String | Symbol | Currency) : Currency

Wraps the value in a Currency object.

c1 = Money::Currency.find(:usd)
Money::Currency.wrap?(c1)    # => #<Money::Currency @id="usd">
Money::Currency.wrap?("usd") # => #<Money::Currency @id="usd">
Money::Currency.wrap?(:usd)  # => #<Money::Currency @id="usd">
Money::Currency.wrap?(:foo)  # => nil
Source

Class methods

register(currency : Currency)
Source
table

List of known currencies.

Source
unregister(currency : Currency)
Source
unregister(currency_code : String | Symbol)
Source
wrap?(value : String | Symbol | Currency) : Currency | Nil

Wraps the value in a Currency object.

c1 = Money::Currency.find(:usd)
Money::Currency.wrap?(c1)    # => #<Money::Currency @id="usd">
Money::Currency.wrap?("usd") # => #<Money::Currency @id="usd">
Money::Currency.wrap?(:usd)  # => #<Money::Currency @id="usd">
Money::Currency.wrap?(:foo)  # => nil
Source

Instance methods

<=>(other : Currency) : Int32

Compares self with other currency against the value of priority and id attributes.

Source
<=>(other : String | Symbol) : Int32

Compares self with other currency against the value of id` attribute.

Source
==(other : self)

Returns true if this reference is the same as other. Invokes same?.

alternate_symbols
Source
code
Source
decimal_mark
Source
decimal_places

Alias of #exponent.

Source
disambiguate_symbol
Source
exponent

Returns the relation between subunit and unit as a base 10 exponent.

NOTE: MGA and MRU are exceptions and are rounded to 1.

See Active_codes.

Source
hash(hasher)

See Object#hash(hasher)

html_entity
Source
id

Currency ID, for time being lower-cased #code.

Source
iso?

Returns true if iso currency.

See #iso_numeric.

Source
iso_numeric
Source
name
Source
priority
Source
smallest_denomination
Source
subunit
Source
subunit_to_unit
Source
symbol
Source
symbol_first?
Source
thousands_separator
Source
to_s(io : IO) : Nil

Appends a string representation corresponding to the #code property to the given io.

Money::Currency.find(:usd).to_s # => "USD"
Money::Currency.find(:eur).to_s # => "EUR"
Source

Nested types