money 6.11.0 → 6.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8de2a6b8bf58ff5719f33d9db889ae722fa39b41
4
- data.tar.gz: 713995a09dfac0042e598c153f3d7dffa54e06d7
3
+ metadata.gz: d1d4f4df8ad562014dbb4ae22806844149097c84
4
+ data.tar.gz: cd1dfde292d4ce67beb09c59d0c793f6b2f99e83
5
5
  SHA512:
6
- metadata.gz: 86cd80fd6278138aa30cdf281e92bfc369035fe7122d98f78ebdd3662810fe7ead3a252e7dea8f40f6600df6c23134f2038e8f8a685fd3065306ef06b81a8f6b
7
- data.tar.gz: e8ed3c0961bbb92ab3cb5523620f08fab61c1c9741819bf2f892c039fd8d5b550843113a71b984dc249ebdb5aa9cbf2f0291b813085c940648f647cb6764f404
6
+ metadata.gz: 1ef2ea4a84d5f2ac90b2dd189aac326d4149412a85c4a8bd70d3fa55237a0bcc610cb5b410b96d1d2c97a613e34ed94189216afed15718f081385ffca5d1545d
7
+ data.tar.gz: a83595b34a6947923d0f4fc7cf8ecaadd7ef3d46f41840fb65c28d616312259610e1c6ce0be584dde111b3aab903f6a294feac1745788a2e661784daceb44569
@@ -174,7 +174,7 @@
174
174
  - Works on Ruby 1.8.7
175
175
  - Update deps
176
176
  - Depreciate Money.parse
177
- - Passing :symbol => false when formatting 'JPY' currency in :ja locale
177
+ - Passing symbol: false when formatting 'JPY' currency in :ja locale
178
178
  will work as expected
179
179
  - Divide now obeys the specified rounding mode
180
180
  - Add Money#round method. This is helpful when working in infinite_precision mode and would like to perform rounding at specific points in your work flow.
@@ -357,7 +357,7 @@ Features
357
357
 
358
358
  Bugfixes
359
359
  --------
360
- - Fixed issue with #format(:no_cents => true) (thanks Romain & Julien)
360
+ - Fixed issue with #format(no_cents: true) (thanks Romain & Julien)
361
361
 
362
362
  Money 3.5.5
363
363
  ===========
@@ -444,7 +444,7 @@ Features
444
444
  - Deprecated `Money#format` with separate params instead of Hash. Deprecation
445
445
  target set to Money 3.5.0.
446
446
  ([#issue/31](http://github.com/RubyMoney/money/issues/31))
447
- - Deprecated `Money#new(0, :currency => "EUR")` in favor of
447
+ - Deprecated `Money#new(0, currency: "EUR")` in favor of
448
448
  `Money#new(0, "EUR")`. Deprecation target set to Money 3.5.0.
449
449
  ([#issue/31](http://github.com/RubyMoney/money/issues/31))
450
450
  - Throw ArgumentError when trying to multiply two Money objects together.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'coveralls', '>= 0.8.17', :require => false
4
- gem 'pry', :require => false
3
+ gem 'coveralls', '>= 0.8.17', require: false
4
+ gem 'pry', require: false
5
5
 
6
6
  # JSON gem no longer supports ruby < 2.0.0
7
7
  if defined?(JRUBY_VERSION)
data/README.md CHANGED
@@ -119,15 +119,15 @@ below.
119
119
 
120
120
  ``` ruby
121
121
  curr = {
122
- :priority => 1,
123
- :iso_code => "USD",
124
- :iso_numeric => "840",
125
- :name => "United States Dollar",
126
- :symbol => "$",
127
- :subunit => "Cent",
128
- :subunit_to_unit => 100,
129
- :decimal_mark => ".",
130
- :thousands_separator => ","
122
+ priority: 1,
123
+ iso_code: "USD",
124
+ iso_numeric: "840",
125
+ name: "United States Dollar",
126
+ symbol: "$",
127
+ subunit: "Cent",
128
+ subunit_to_unit: 100,
129
+ decimal_mark: ".",
130
+ thousands_separator: ","
131
131
  }
132
132
 
133
133
  Money::Currency.register(curr)
@@ -317,12 +317,12 @@ The following example implements an `ActiveRecord` store to save exchange rates
317
317
  # for Rails 5 replace ActiveRecord::Base with ApplicationRecord
318
318
  class ExchangeRate < ActiveRecord::Base
319
319
  def self.get_rate(from_iso_code, to_iso_code)
320
- rate = find_by(:from => from_iso_code, :to => to_iso_code)
320
+ rate = find_by(from: from_iso_code, to: to_iso_code)
321
321
  rate.present? ? rate.rate : nil
322
322
  end
323
323
 
324
324
  def self.add_rate(from_iso_code, to_iso_code, rate)
325
- exrate = find_or_initialize_by(:from => from_iso_code, :to => to_iso_code)
325
+ exrate = find_or_initialize_by(from: from_iso_code, to: to_iso_code)
326
326
  exrate.rate = rate
327
327
  exrate.save!
328
328
  end
@@ -379,6 +379,17 @@ implementations.
379
379
  - [russian_central_bank](https://github.com/rmustafin/russian_central_bank)
380
380
  - [money-uphold-bank](https://github.com/subvisual/money-uphold-bank)
381
381
 
382
+ ## Formatting
383
+
384
+ There are several formatting rules for when `Money#format` is called. For more information, check out the [formatting module source](https://github.com/RubyMoney/money/blob/master/lib/money/money/formatter.rb), or read the latest release's [rdoc version](http://www.rubydoc.info/gems/money/Money/Formatter).
385
+
386
+ If you wish to format money according to the EU's [Rules for expressing monetary units](http://publications.europa.eu/code/en/en-370303.htm#position) in either English, Irish, Latvian or Maltese:
387
+
388
+ ```ruby
389
+ m = Money.new('123', :gbp) # => #<Money fractional:123 currency:GBP>
390
+ m.format(symbol: m.currency.to_s + ' ') # => "GBP 1.23"
391
+ ```
392
+
382
393
  ## Ruby on Rails
383
394
 
384
395
  To integrate money in a Rails application use [money-rails](https://github.com/RubyMoney/money-rails).
@@ -415,6 +426,11 @@ If you wish to disable this feature:
415
426
  Money.use_i18n = false
416
427
  ```
417
428
 
429
+ ## Collection
430
+
431
+ In case you're working with collections of `Money` instances, have a look at [money-collection](https://github.com/RubyMoney/money-collection)
432
+ for improved performance and accuracy.
433
+
418
434
  ### Troubleshooting
419
435
 
420
436
  If you get a runtime error such as:
@@ -426,16 +442,6 @@ Set the following:
426
442
  I18n.enforce_available_locales = false
427
443
  ```
428
444
 
429
- ## Formatting
430
-
431
- There are several formatting rules for when `Money#format` is called. For more information, check out the [formatting module source](https://github.com/RubyMoney/money/blob/master/lib/money/money/formatting.rb), or read the latest release's [rdoc version](http://www.rubydoc.info/gems/money/Money/Formatting).
432
-
433
- If you wish to format money according to the EU's [Rules for expressing monetary units](http://publications.europa.eu/code/en/en-370303.htm#position) in either English, Irish, Latvian or Maltese:
434
- ```ruby
435
- m = Money.new('123', :gbp) # => #<Money fractional:123 currency:GBP>
436
- m.format( symbol: m.currency.to_s + ' ') # => "GBP 1.23"
437
- ```
438
-
439
445
  ## Heuristics
440
446
 
441
447
  Prior to v6.9.0 heuristic analysis of string input was part of this gem. Since then it was extracted in to [money-heuristics gem](https://github.com/RubyMoney/money-heuristics).
@@ -47,7 +47,7 @@ class Money
47
47
  # Available formats for importing/exporting rates.
48
48
  RATE_FORMATS = [:json, :ruby, :yaml].freeze
49
49
  SERIALIZER_SEPARATOR = '_TO_'.freeze
50
- FORMAT_SERIALIZERS = {:json => JSON, :ruby => Marshal, :yaml => YAML}.freeze
50
+ FORMAT_SERIALIZERS = {json: JSON, ruby: Marshal, yaml: YAML}.freeze
51
51
 
52
52
  # Initializes a new +Money::Bank::VariableExchange+ object.
53
53
  # It defaults to using an in-memory, thread safe store instance for
@@ -17,7 +17,7 @@ class Money
17
17
  def parse_currency_file(filename)
18
18
  json = File.read("#{DATA_PATH}/#{filename}")
19
19
  json.force_encoding(::Encoding::UTF_8) if defined?(::Encoding)
20
- JSON.parse(json, :symbolize_names => true)
20
+ JSON.parse(json, symbolize_names: true)
21
21
  end
22
22
  end
23
23
  end
@@ -104,9 +104,9 @@ class Money
104
104
  # @see +Money::Formatting#format+ for more details.
105
105
  #
106
106
  # @example
107
- # Money.default_formatting_rules = { :display_free => true }
107
+ # Money.default_formatting_rules = { display_free: true }
108
108
  # Money.new(0, "USD").format # => "free"
109
- # Money.new(0, "USD").format(:display_free => false) # => "$0.00"
109
+ # Money.new(0, "USD").format(display_free: false) # => "$0.00"
110
110
  #
111
111
  # @!attribute [rw] use_i18n
112
112
  # @return [Boolean] Use this to disable i18n even if it's used by other
@@ -351,19 +351,10 @@ class Money
351
351
  # @example
352
352
  # Money.ca_dollar(100).to_s #=> "1.00"
353
353
  def to_s
354
- unit, subunit, fraction = strings_from_fractional
355
-
356
- str = if currency.decimal_places == 0
357
- if fraction == ""
358
- unit
359
- else
360
- "#{unit}#{currency.decimal_mark}#{fraction}"
361
- end
362
- else
363
- "#{unit}#{currency.decimal_mark}#{pad_subunit(subunit)}#{fraction}"
364
- end
365
-
366
- fractional < 0 ? "-#{str}" : str
354
+ format decimal_mark: currency.decimal_mark,
355
+ thousands_separator: '',
356
+ no_cents_if_whole: currency.decimal_places == 0,
357
+ symbol: false
367
358
  end
368
359
 
369
360
  # Return the amount of money as a BigDecimal.
@@ -575,32 +566,6 @@ class Money
575
566
  end
576
567
  end
577
568
 
578
- def strings_from_fractional
579
- unit, subunit = fractional().abs.divmod(currency.subunit_to_unit)
580
-
581
- if self.class.infinite_precision
582
- strings_for_infinite_precision(unit, subunit)
583
- else
584
- strings_for_base_precision(unit, subunit)
585
- end
586
- end
587
-
588
- def strings_for_infinite_precision(unit, subunit)
589
- subunit, fraction = subunit.divmod(BigDecimal("1"))
590
- fraction = fraction.to_s("F")[2..-1] # want fractional part "0.xxx"
591
- fraction = "" if fraction =~ /^0+$/
592
-
593
- [unit.to_i.to_s, subunit.to_i.to_s, fraction]
594
- end
595
-
596
- def strings_for_base_precision(unit, subunit)
597
- [unit.to_s, subunit.to_s, ""]
598
- end
599
-
600
- def pad_subunit(subunit)
601
- subunit.rjust(currency.decimal_places, '0')
602
- end
603
-
604
569
  def amounts_from_splits(splits)
605
570
  allocations = splits.inject(0, :+)
606
571
  left_over = fractional
@@ -126,7 +126,7 @@ class Money
126
126
  define_method(op) do |other|
127
127
  unless other.is_a?(Money)
128
128
  if other.zero?
129
- return other.is_a?(CoercedNumeric) ? Money.empty.public_send(op, self) : self
129
+ return other.is_a?(CoercedNumeric) ? Money.empty(currency).public_send(op, self) : self
130
130
  end
131
131
  raise TypeError
132
132
  end
@@ -13,8 +13,8 @@ class Money
13
13
  # amount of money should be formatted of "free" or as the supplied string.
14
14
  #
15
15
  # @example
16
- # Money.us_dollar(0).format(:display_free => true) #=> "free"
17
- # Money.us_dollar(0).format(:display_free => "gratis") #=> "gratis"
16
+ # Money.us_dollar(0).format(display_free: true) #=> "free"
17
+ # Money.us_dollar(0).format(display_free: "gratis") #=> "gratis"
18
18
  # Money.us_dollar(0).format #=> "$0.00"
19
19
  #
20
20
  # @option rules [Boolean] :with_currency (false) Whether the currency name
@@ -22,29 +22,29 @@ class Money
22
22
  #
23
23
  # @example
24
24
  # Money.ca_dollar(100).format #=> "$1.00"
25
- # Money.ca_dollar(100).format(:with_currency => true) #=> "$1.00 CAD"
26
- # Money.us_dollar(85).format(:with_currency => true) #=> "$0.85 USD"
25
+ # Money.ca_dollar(100).format(with_currency: true) #=> "$1.00 CAD"
26
+ # Money.us_dollar(85).format(with_currency: true) #=> "$0.85 USD"
27
27
  #
28
28
  # @option rules [Boolean] :rounded_infinite_precision (false) Whether the
29
29
  # amount of money should be rounded when using {infinite_precision}
30
30
  #
31
31
  # @example
32
32
  # Money.us_dollar(100.1).format #=> "$1.001"
33
- # Money.us_dollar(100.1).format(:rounded_infinite_precision => true) #=> "$1"
34
- # Money.us_dollar(100.9).format(:rounded_infinite_precision => true) #=> "$1.01"
33
+ # Money.us_dollar(100.1).format(rounded_infinite_precision: true) #=> "$1"
34
+ # Money.us_dollar(100.9).format(rounded_infinite_precision: true) #=> "$1.01"
35
35
  #
36
36
  # @option rules [Boolean] :no_cents (false) Whether cents should be omitted.
37
37
  #
38
38
  # @example
39
- # Money.ca_dollar(100).format(:no_cents => true) #=> "$1"
40
- # Money.ca_dollar(599).format(:no_cents => true) #=> "$5"
39
+ # Money.ca_dollar(100).format(no_cents: true) #=> "$1"
40
+ # Money.ca_dollar(599).format(no_cents: true) #=> "$5"
41
41
  #
42
42
  # @option rules [Boolean] :no_cents_if_whole (false) Whether cents should be
43
43
  # omitted if the cent value is zero
44
44
  #
45
45
  # @example
46
- # Money.ca_dollar(10000).format(:no_cents_if_whole => true) #=> "$100"
47
- # Money.ca_dollar(10034).format(:no_cents_if_whole => true) #=> "$100.34"
46
+ # Money.ca_dollar(10000).format(no_cents_if_whole: true) #=> "$100"
47
+ # Money.ca_dollar(10034).format(no_cents_if_whole: true) #=> "$100.34"
48
48
  #
49
49
  # @option rules [Boolean, String, nil] :symbol (true) Whether a money symbol
50
50
  # should be prepended to the result string. The default is true. This method
@@ -56,26 +56,26 @@ class Money
56
56
  # Money.new(100, "EUR") #=> "€1.00"
57
57
  #
58
58
  # # Same thing.
59
- # Money.new(100, "USD").format(:symbol => true) #=> "$1.00"
60
- # Money.new(100, "GBP").format(:symbol => true) #=> "£1.00"
61
- # Money.new(100, "EUR").format(:symbol => true) #=> "€1.00"
59
+ # Money.new(100, "USD").format(symbol: true) #=> "$1.00"
60
+ # Money.new(100, "GBP").format(symbol: true) #=> "£1.00"
61
+ # Money.new(100, "EUR").format(symbol: true) #=> "€1.00"
62
62
  #
63
63
  # # You can specify a false expression or an empty string to disable
64
64
  # # prepending a money symbol.§
65
- # Money.new(100, "USD").format(:symbol => false) #=> "1.00"
66
- # Money.new(100, "GBP").format(:symbol => nil) #=> "1.00"
67
- # Money.new(100, "EUR").format(:symbol => "") #=> "1.00"
65
+ # Money.new(100, "USD").format(symbol: false) #=> "1.00"
66
+ # Money.new(100, "GBP").format(symbol: nil) #=> "1.00"
67
+ # Money.new(100, "EUR").format(symbol: "") #=> "1.00"
68
68
  #
69
69
  # # If the symbol for the given currency isn't known, then it will default
70
70
  # # to "¤" as symbol.
71
- # Money.new(100, "AWG").format(:symbol => true) #=> "¤1.00"
71
+ # Money.new(100, "AWG").format(symbol: true) #=> "¤1.00"
72
72
  #
73
73
  # # You can specify a string as value to enforce using a particular symbol.
74
- # Money.new(100, "AWG").format(:symbol => "ƒ") #=> "ƒ1.00"
74
+ # Money.new(100, "AWG").format(symbol: "ƒ") #=> "ƒ1.00"
75
75
  #
76
76
  # # You can specify a indian currency format
77
- # Money.new(10000000, "INR").format(:south_asian_number_formatting => true) #=> "1,00,000.00"
78
- # Money.new(10000000).format(:south_asian_number_formatting => true) #=> "$1,00,000.00"
77
+ # Money.new(10000000, "INR").format(south_asian_number_formatting: true) #=> "1,00,000.00"
78
+ # Money.new(10000000).format(south_asian_number_formatting: true) #=> "$1,00,000.00"
79
79
  #
80
80
  # @option rules [Boolean, nil] :symbol_before_without_space (true) Whether
81
81
  # a space between the money symbol and the amount should be inserted when
@@ -87,10 +87,10 @@ class Money
87
87
  # Money.new(100, "USD").format #=> "$1.00"
88
88
  #
89
89
  # # Same thing.
90
- # Money.new(100, "USD").format(:symbol_before_without_space => true) #=> "$1.00"
90
+ # Money.new(100, "USD").format(symbol_before_without_space: true) #=> "$1.00"
91
91
  #
92
92
  # # If set to false, will insert a space.
93
- # Money.new(100, "USD").format(:symbol_before_without_space => false) #=> "$ 1.00"
93
+ # Money.new(100, "USD").format(symbol_before_without_space: false) #=> "$ 1.00"
94
94
  #
95
95
  # @option rules [Boolean, nil] :symbol_after_without_space (false) Whether
96
96
  # a space between the amount and the money symbol should be inserted when
@@ -99,17 +99,17 @@ class Money
99
99
  #
100
100
  # @example
101
101
  # # Default is to insert a space.
102
- # Money.new(100, "USD").format(:symbol_position => :after) #=> "1.00 $"
102
+ # Money.new(100, "USD").format(symbol_position: :after) #=> "1.00 $"
103
103
  #
104
104
  # # If set to true, will not insert a space.
105
- # Money.new(100, "USD").format(:symbol_position => :after, :symbol_after_without_space => true) #=> "1.00$"
105
+ # Money.new(100, "USD").format(symbol_position: :after, symbol_after_without_space: true) #=> "1.00$"
106
106
  #
107
107
  # @option rules [Boolean, String, nil] :decimal_mark (true) Whether the
108
108
  # currency should be separated by the specified character or '.'
109
109
  #
110
110
  # @example
111
111
  # # If a string is specified, it's value is used.
112
- # Money.new(100, "USD").format(:decimal_mark => ",") #=> "$1,00"
112
+ # Money.new(100, "USD").format(decimal_mark: ",") #=> "$1,00"
113
113
  #
114
114
  # # If the decimal_mark for a given currency isn't known, then it will default
115
115
  # # to "." as decimal_mark.
@@ -120,12 +120,12 @@ class Money
120
120
  #
121
121
  # @example
122
122
  # # If false is specified, no thousands_separator is used.
123
- # Money.new(100000, "USD").format(:thousands_separator => false) #=> "1000.00"
124
- # Money.new(100000, "USD").format(:thousands_separator => nil) #=> "1000.00"
125
- # Money.new(100000, "USD").format(:thousands_separator => "") #=> "1000.00"
123
+ # Money.new(100000, "USD").format(thousands_separator: false) #=> "1000.00"
124
+ # Money.new(100000, "USD").format(thousands_separator: nil) #=> "1000.00"
125
+ # Money.new(100000, "USD").format(thousands_separator: "") #=> "1000.00"
126
126
  #
127
127
  # # If a string is specified, it's value is used.
128
- # Money.new(100000, "USD").format(:thousands_separator => ".") #=> "$1.000.00"
128
+ # Money.new(100000, "USD").format(thousands_separator: ".") #=> "$1.000.00"
129
129
  #
130
130
  # # If the thousands_separator for a given currency isn't known, then it will
131
131
  # # default to "," as thousands_separator.
@@ -135,7 +135,7 @@ class Money
135
135
  # HTML-formatted. Only useful in combination with +:with_currency+.
136
136
  #
137
137
  # @example
138
- # Money.ca_dollar(570).format(:html => true, :with_currency => true)
138
+ # Money.ca_dollar(570).format(html: true, with_currency: true)
139
139
  # #=> "$5.70 <span class=\"currency\">CAD</span>"
140
140
  #
141
141
  # @option rules [Boolean] :sign_before_symbol (false) Whether the sign should be
@@ -143,8 +143,8 @@ class Money
143
143
  #
144
144
  # @example
145
145
  # # You can specify to display the sign before the symbol for negative numbers
146
- # Money.new(-100, "GBP").format(:sign_before_symbol => true) #=> "-£1.00"
147
- # Money.new(-100, "GBP").format(:sign_before_symbol => false) #=> "£-1.00"
146
+ # Money.new(-100, "GBP").format(sign_before_symbol: true) #=> "-£1.00"
147
+ # Money.new(-100, "GBP").format(sign_before_symbol: false) #=> "£-1.00"
148
148
  # Money.new(-100, "GBP").format #=> "£-1.00"
149
149
  #
150
150
  # @option rules [Boolean] :sign_positive (false) Whether positive numbers should be
@@ -152,34 +152,34 @@ class Money
152
152
  #
153
153
  # @example
154
154
  # # You can specify to display the sign with positive numbers
155
- # Money.new(100, "GBP").format(:sign_positive => true, :sign_before_symbol => true) #=> "+£1.00"
156
- # Money.new(100, "GBP").format(:sign_positive => true, :sign_before_symbol => false) #=> "£+1.00"
157
- # Money.new(100, "GBP").format(:sign_positive => false, :sign_before_symbol => true) #=> "£1.00"
158
- # Money.new(100, "GBP").format(:sign_positive => false, :sign_before_symbol => false) #=> "£1.00"
155
+ # Money.new(100, "GBP").format(sign_positive: true, sign_before_symbol: true) #=> "+£1.00"
156
+ # Money.new(100, "GBP").format(sign_positive: true, sign_before_symbol: false) #=> "£+1.00"
157
+ # Money.new(100, "GBP").format(sign_positive: false, sign_before_symbol: true) #=> "£1.00"
158
+ # Money.new(100, "GBP").format(sign_positive: false, sign_before_symbol: false) #=> "£1.00"
159
159
  # Money.new(100, "GBP").format #=> "£+1.00"
160
160
  #
161
161
  # @option rules [Boolean] :disambiguate (false) Prevents the result from being ambiguous
162
162
  # due to equal symbols for different currencies. Uses the `disambiguate_symbol`.
163
163
  #
164
164
  # @example
165
- # Money.new(10000, "USD").format(:disambiguate => false) #=> "$100.00"
166
- # Money.new(10000, "CAD").format(:disambiguate => false) #=> "$100.00"
167
- # Money.new(10000, "USD").format(:disambiguate => true) #=> "$100.00"
168
- # Money.new(10000, "CAD").format(:disambiguate => true) #=> "C$100.00"
165
+ # Money.new(10000, "USD").format(disambiguate: false) #=> "$100.00"
166
+ # Money.new(10000, "CAD").format(disambiguate: false) #=> "$100.00"
167
+ # Money.new(10000, "USD").format(disambiguate: true) #=> "$100.00"
168
+ # Money.new(10000, "CAD").format(disambiguate: true) #=> "C$100.00"
169
169
  #
170
170
  # @option rules [Boolean] :html_wrap_symbol (false) Wraps the currency symbol
171
171
  # in a html <span> tag.
172
172
  #
173
173
  # @example
174
- # Money.new(10000, "USD").format(:disambiguate => false)
174
+ # Money.new(10000, "USD").format(disambiguate: false)
175
175
  # #=> "<span class=\"currency_symbol\">$100.00</span>
176
176
  #
177
177
  # @option rules [Symbol] :symbol_position (:before) `:before` if the currency
178
178
  # symbol goes before the amount, `:after` if it goes after.
179
179
  #
180
180
  # @example
181
- # Money.new(10000, "USD").format(:symbol_position => :before) #=> "$100.00"
182
- # Money.new(10000, "USD").format(:symbol_position => :after) #=> "100.00 $"
181
+ # Money.new(10000, "USD").format(symbol_position: :before) #=> "$100.00"
182
+ # Money.new(10000, "USD").format(symbol_position: :after) #=> "100.00 $"
183
183
  #
184
184
  # @option rules [Boolean] :translate (true) `true` Checks for custom
185
185
  # symbol definitions using I18n.
@@ -191,11 +191,11 @@ class Money
191
191
  # # currency:
192
192
  # # symbol:
193
193
  # # CAD: "CAD$"
194
- # Money.new(10000, "CAD").format(:translate => true) #=> "CAD$100.00"
194
+ # Money.new(10000, "CAD").format(translate: true) #=> "CAD$100.00"
195
195
  #
196
196
  # @example
197
- # Money.new(89000, :btc).format(:drop_trailing_zeros => true) #=> B⃦0.00089
198
- # Money.new(110, :usd).format(:drop_trailing_zeros => true) #=> $1.1
197
+ # Money.new(89000, :btc).format(drop_trailing_zeros: true) #=> B⃦0.00089
198
+ # Money.new(110, :usd).format(drop_trailing_zeros: true) #=> $1.1
199
199
  #
200
200
  # Note that the default rules can be defined through {Money.default_formatting_rules} hash.
201
201
  #
@@ -312,7 +312,7 @@ class Money
312
312
  end
313
313
 
314
314
  def format_decimal_part(value)
315
- return nil if currency.decimal_places == 0
315
+ return nil if currency.decimal_places == 0 && !Money.infinite_precision
316
316
  return nil if rules[:no_cents]
317
317
  return nil if rules[:no_cents_if_whole] && value.to_i == 0
318
318
 
@@ -328,9 +328,9 @@ class Money
328
328
  def i18n_format_for(method, name, character)
329
329
  if Money.use_i18n
330
330
  begin
331
- I18n.t name, :scope => "number.currency.format", :raise => true
331
+ I18n.t name, scope: "number.currency.format", raise: true
332
332
  rescue I18n::MissingTranslationData
333
- I18n.t name, :scope =>"number.format", :default => (currency.send(method) || character)
333
+ I18n.t name, scope: "number.format", default: (currency.send(method) || character)
334
334
  end
335
335
  else
336
336
  currency.send(method) || character