Money::Currency
Inherits JSON::Serializable / Comparable / Comparable / Reference / Object
Represents a specific currency unit.
See ISO 4217.
Constructors
new(pull : JSON::PullParser)
Sourcenew(*, 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)
Sourcenew(*, __pull_for_json_serializable pull : JSON::PullParser)
Sourcewrap(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
Class methods
register(currency : Currency)
Sourceunregister(currency : Currency)
Sourceunregister(currency_code : String | Symbol)
Sourcewrap?(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
Instance methods
<=>(other : Currency) : Int32
Compares self with other currency against the value of
priority and id attributes.
<=>(other : String | Symbol) : Int32
Compares self with other currency against the value of id` attribute.
==(other : self)
Returns true if this reference is the same as other. Invokes same?.
alternate_symbols
Sourcecode
Sourcedecimal_mark
Sourcedisambiguate_symbol
Sourceexponent
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.
hash(hasher)
See Object#hash(hasher)
html_entity
Sourceiso_numeric
Sourcename
Sourcepriority
Sourcesmallest_denomination
Sourcesubunit
Sourcesubunit_to_unit
Sourcesymbol
Sourcesymbol_first?
Sourcethousands_separator
Sourceto_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"