class Money::Currency
- Money::Currency
- Reference
- Object
Overview
Represents a specific currency unit.
See ISO 4217.
Included Modules
- Comparable(String | Symbol)
- Comparable(Money::Currency)
- JSON::Serializable
Extended Modules
Defined in:
money/currency.crmoney/currency/enumeration.cr
money/currency/json.cr
money/currency/loader.cr
money/currency/rate.cr
money/currency/rate_store.cr
money/currency/rate_store/memory.cr
Constructors
- .new(pull : JSON::PullParser)
- .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)
-
.wrap(value : String | Symbol | Currency) : Currency
Wraps the value in a
Currency
object.
Class Method Summary
- .register(currency : Currency)
-
.table : Hash(String, Currency)
List of known currencies.
- .unregister(currency : Currency)
- .unregister(currency_code : String | Symbol)
-
.wrap?(value : String | Symbol | Currency) : Currency | Nil
Wraps the value in a
Currency
object.
Instance Method Summary
- #<=>(other : Currency) : Int32
-
#<=>(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. - #alternate_symbols : Array(String) | Nil
- #code : String
- #decimal_mark : String | Nil
-
#decimal_places : Int32
Alias of
#exponent
. - #disambiguate_symbol : String | Nil
-
#exponent : Int32
Returns the relation between subunit and unit as a base 10 exponent.
-
#hash(hasher)
See
Object#hash(hasher)
- #html_entity : String | Nil
-
#id : String
Currency ID, for time being lower-cased
#code
. -
#iso?
Returns
true
if iso currency. - #iso_numeric : UInt32 | Nil
- #name : String | Nil
- #priority : Int32 | Nil
- #smallest_denomination : UInt32 | Nil
- #subunit : String | Nil
- #subunit_to_unit : UInt64
- #symbol : String | Nil
- #symbol_first? : Bool | Nil
- #thousands_separator : String | Nil
-
#to_s(io : IO) : Nil
Appends a string representation corresponding to the
#code
property to the given io.
Constructor Detail
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 Method Detail
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 Method Detail
Compares self
with other currency against the value of id` attribute.
Returns true
if this reference is the same as other. Invokes same?
.
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.