Class: Money::Formatter
- Inherits:
-
Object
- Object
- Money::Formatter
- Defined in:
- lib/money/money/formatter.rb
Constant Summary collapse
- DEFAULTS =
{ thousands_separator: '', decimal_mark: '.' }.freeze
Instance Method Summary collapse
- #decimal_mark ⇒ Object (also: #separator)
-
#initialize(money, *rules) ⇒ String
constructor
Creates a formatted price string according to several rules.
- #thousands_separator ⇒ Object (also: #delimiter)
- #to_s ⇒ Object
Constructor Details
#initialize(money, *rules) ⇒ String
Creates a formatted price string according to several rules.
with the symbol (if present) and ‘%n` will be replaced with the number.
Note that the default rules can be defined through Money.default_formatting_rules hash.
230 231 232 233 234 |
# File 'lib/money/money/formatter.rb', line 230 def initialize(money, *rules) @money = money @currency = money.currency @rules = FormattingRules.new(@currency, *rules) end |
Instance Method Details
#decimal_mark ⇒ Object Also known as: separator
247 248 249 |
# File 'lib/money/money/formatter.rb', line 247 def decimal_mark lookup :decimal_mark end |
#thousands_separator ⇒ Object Also known as: delimiter
243 244 245 |
# File 'lib/money/money/formatter.rb', line 243 def thousands_separator lookup :thousands_separator end |
#to_s ⇒ Object
236 237 238 239 240 241 |
# File 'lib/money/money/formatter.rb', line 236 def to_s return free_text if show_free_text? result = format_number formatted = append_sign(result) append_currency_symbol(formatted) end |