module Money::Currency::Enumeration

Included Modules

Defined in:

money/currency/enumeration.cr

Instance Method Summary

Instance Method Detail

def [](key : String | Symbol) : Currency #

Alias of #find.


[View source]
def [](key : Currency) : Currency #

Returns given Currency instance.


[View source]
def []?(key : String | Symbol) : Currency | Nil #

Alias of #find?.


[View source]
def []?(key : Currency) : Currency | Nil #

Returns given Currency instance.


[View source]
def all : Array(Currency) #

Returns a sorted list of all registered currencies.


[View source]
def each(& : Currency -> _) : Nil #

Iterates over all registered currencies.


[View source]
def find(key : String | Symbol) : Currency #

Looks up a currency with the given key and returns a Currency instance on success, raises UnknownCurrencyError otherwise.

Money::Currency.find("EUR") # => #<Money::Currency @code="EUR">
Money::Currency.find("FOO") # => raises UnknownCurrencyError

[View source]
def find?(key : String | Symbol) : Currency | Nil #

Looks up a currency with the given key and returns a Currency instance on success, nil otherwise.

Money::Currency.find?("EUR") # => #<Money::Currency @code="EUR">
Money::Currency.find?("FOO") # => nil

[View source]