Class: Money::Currency
- Inherits:
-
Struct
- Object
- Struct
- Money::Currency
- Defined in:
- lib/money/currency.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id
4 5 6 |
# File 'lib/money/currency.rb', line 4 def id @id end |
Class Method Details
.[](currency) ⇒ Object
10 11 12 13 |
# File 'lib/money/currency.rb', line 10 def self.[](currency) return currency if currency.kind_of?(self) Currency.new(currency) end |
.exchange(&block) ⇒ Object
6 7 8 |
# File 'lib/money/currency.rb', line 6 def self.exchange(&block) @@exchange_handler = block end |
Instance Method Details
#to(other_currency, on:) ⇒ Object
15 16 17 18 19 |
# File 'lib/money/currency.rb', line 15 def to(other_currency, on:) other_currency = Currency[other_currency] return Money.new(1.0, self, on) if self == other_currency Money.new(call_exchange_handler(other_currency, on), other_currency, on) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/money/currency.rb', line 21 def to_s id end |