Class: Mint::Currency
- Inherits:
-
Object
- Object
- Mint::Currency
- Defined in:
- lib/minting/mint/currency.rb
Overview
Represents a specific currency unit, identified by ISO 4217 alphabetic code
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#fractional_multiplier ⇒ Object
readonly
Returns the value of attribute fractional_multiplier.
-
#minimum_amount ⇒ Object
readonly
Returns the value of attribute minimum_amount.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#subunit ⇒ Object
readonly
Returns the value of attribute subunit.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Instance Method Summary collapse
- #inspect ⇒ Object
-
#normalize_amount(amount) ⇒ Object
Normalizes numeric amounts for this currency 1.
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def code @code end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def country @country end |
#fractional_multiplier ⇒ Object (readonly)
Returns the value of attribute fractional_multiplier.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def fractional_multiplier @fractional_multiplier end |
#minimum_amount ⇒ Object (readonly)
Returns the value of attribute minimum_amount.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def minimum_amount @minimum_amount end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def name @name end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def priority @priority end |
#subunit ⇒ Object (readonly)
Returns the value of attribute subunit.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def subunit @subunit end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
8 9 10 |
# File 'lib/minting/mint/currency.rb', line 8 def symbol @symbol end |
Instance Method Details
#inspect ⇒ Object
13 |
# File 'lib/minting/mint/currency.rb', line 13 def inspect = "<Currency:(#{code} #{symbol} #{subunit} #{name})>" |
#normalize_amount(amount) ⇒ Object
Normalizes numeric amounts for this currency
-
Converts to Rational
-
Rounds to respect currency subunit
18 |
# File 'lib/minting/mint/currency.rb', line 18 def normalize_amount(amount) = amount.to_r.round(subunit) |