latinum 1.6.0 → 1.7.0

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
  SHA256:
3
- metadata.gz: dc3529356aeebbfb020336961b359bd2a78f3473504bd8d5e81e5c19fb709f5a
4
- data.tar.gz: bc57d00b4a80bf91a059709a973941a017e3c63324936942956ae5962c499640
3
+ metadata.gz: 9c055e958ac724d131bdbb261f18f6f8b6e6f475a77d633710077a0722c19ffc
4
+ data.tar.gz: 258a4c2c4233bc9e030a9e5cec7b685c0f7563bb012427809a6c6901067f69f1
5
5
  SHA512:
6
- metadata.gz: 134e6a9444aac017ce38d3239fbec37d11f7407324b386aa6ac3d56b06ccc9f4af2b9b7df6295382d4f33c3c7d171fdc4351da748d9ce2b8cd7993d2b01b77b2
7
- data.tar.gz: 8b4b674b1ba7a8d3170c190674eecb7efb741a2814f3d0a55751794baa2f974cf098c2798b85560c1b75b56f0423005b0e7a5e2aa2a8a3d2d057cd4c0adab463
6
+ metadata.gz: cd104cf3d2664d37fde830088298544795148a782ff3ad37f9265acfbbac0d1e159d5aba27cbb8dfbac1679f25771fb0a26e902835f3b3417c465defa117d3ea
7
+ data.tar.gz: 6891feee50ec8cb81c7d6f99857ad555d8ad283a1d3729efdf4ed8f92204a3699beae4ef457e06d6e905d7890f5cca6464beb4f92c552da0853682ba3e671da5
@@ -55,7 +55,7 @@ module Latinum
55
55
  def initialize(**options)
56
56
  @symbol = options[:symbol] || '$'
57
57
  @separator = options[:separator] || '.'
58
- @delimeter = options[:delimter] || ','
58
+ @delimeter = options[:delimeter] || ','
59
59
  @places = options[:precision] || 2
60
60
  @zero = options[:zero] || '0'
61
61
 
@@ -69,9 +69,9 @@ module Latinum
69
69
  # Formats the amount using the configured symbol, separator, delimeter, and places.
70
70
  # e.g. "$5,000.00 NZD". Rounds the amount to the specified number of decimal places.
71
71
  # @returns [String] The formatted string.
72
- def format(amount, **options)
72
+ def format(amount, places: @places, **options)
73
73
  # Round to the desired number of places. Truncation used to be the default.
74
- amount = amount.round(@places)
74
+ amount = amount.round(places).to_d
75
75
 
76
76
  integral, fraction = amount.abs.to_s('F').split(/\./, 2)
77
77
 
@@ -79,7 +79,7 @@ module Latinum
79
79
  sign = '-' if amount < 0
80
80
 
81
81
  # Decimal places, e.g. the '.00' in '$10.00'
82
- fraction = fraction[0...@places].ljust(@places, @zero)
82
+ fraction = fraction[0...places].ljust(places, @zero)
83
83
 
84
84
  # Grouping, e.g. the ',' in '$10,000.00'
85
85
  remainder = integral.size % 3
@@ -92,7 +92,7 @@ module Latinum
92
92
  name = options.fetch(:name, @name)
93
93
  suffix = name ? " #{name}" : ''
94
94
 
95
- if @places > 0
95
+ if places > 0
96
96
  "#{value}#{@separator}#{fraction}#{suffix}"
97
97
  else
98
98
  "#{value}#{suffix}"
@@ -49,7 +49,7 @@ module Latinum
49
49
  end
50
50
  end
51
51
 
52
- # Dump a string representatino of a resource.
52
+ # Dump a string representation of a resource.
53
53
  # @parameter resource [Resource] The resource to dump.
54
54
  # @returns [String | Nil] A string that represents the {Resource}.
55
55
  def self.dump(resource)
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Latinum
24
- VERSION = "1.6.0"
24
+ VERSION = "1.7.0"
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latinum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-06 00:00:00.000000000 Z
11
+ date: 2021-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler