Class: Money::FormattingRules

Inherits:
Object
  • Object
show all
Defined in:
lib/money/money/formatting_rules.rb

Instance Method Summary collapse

Constructor Details

#initialize(currency, *raw_rules) ⇒ FormattingRules

Returns a new instance of FormattingRules.


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/money/money/formatting_rules.rb', line 5

def initialize(currency, *raw_rules)
  @currency = currency

  # support for old format parameters
  @rules = normalize_formatting_rules(raw_rules)

  @rules = default_formatting_rules.merge(@rules) unless @rules[:ignore_defaults]
  @rules = localize_formatting_rules(@rules)
  @rules = translate_formatting_rules(@rules) if @rules[:translate]
  @rules[:format] ||= determine_format_from_formatting_rules(@rules)
  @rules[:delimiter_pattern] ||= delimiter_pattern_rule(@rules)

  warn_about_deprecated_rules(@rules)
end

Instance Method Details

#[](key) ⇒ Object


20
21
22
# File 'lib/money/money/formatting_rules.rb', line 20

def [](key)
  @rules[key]
end

#has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)

24
25
26
# File 'lib/money/money/formatting_rules.rb', line 24

def has_key?(key)
  @rules.has_key? key
end