abstract class
Money::Currency::RateStore
- Money::Currency::RateStore
- Reference
- Object
Included Modules
- Enumerable(Money::Currency::Rate)
Direct Known Subclasses
Defined in:
money/currency/rate_store.crInstance Method Summary
-
#[](from : String | Symbol | Currency, to : String | Symbol | Currency) : BigDecimal
Retrieve the rate for the given currency pair.
-
#[]=(from : String | Symbol | Currency, to : String | Symbol | Currency, value : Number) : Nil
Registers a conversion rate and returns it.
-
#[]?(from : String | Symbol | Currency, to : String | Symbol | Currency) : BigDecimal | Nil
Retrieve the rate for the given currency pair.
-
#clear : Nil
Empties currency rate index.
-
#each(& : Rate -> _) : Nil
Iterates over list of
Rate
objects. -
#transaction(& : -> _)
Wraps block execution in a concurrency-safe transaction.
Instance Method Detail
Retrieve the rate for the given currency pair.
store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["USD", "CAD"]? # => 1.24515
Registers a conversion rate and returns it.
store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["CAD", "USD"] = 0.803115
Retrieve the rate for the given currency pair.
store = Money::Currency::RateStore::Memory.new
store["USD", "CAD"] = 1.24515
store["USD", "CAD"]? # => 1.24515
Iterates over list of Rate
objects.
store.each do |rate|
puts rate
end