money 3.5.1 → 3.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/lib/money/money.rb +8 -2
  3. metadata +9 -2
@@ -1,3 +1,10 @@
1
+ Money 3.5.2
2
+ ===========
3
+
4
+ Bugfixes
5
+ --------
6
+ - Fixed an error in #to_s which appended extra 0s incorrectly
7
+
1
8
  Money 3.5.1
2
9
  ===========
3
10
 
@@ -900,10 +900,16 @@ class Money
900
900
  # @example
901
901
  # Money.ca_dollar(100).to_s #=> "1.00"
902
902
  def to_s
903
- decimal_places = Math.log10(currency.subunit_to_unit).ceil
903
+ decimal_places = if currency.subunit_to_unit == 1
904
+ 0
905
+ elsif currency.subunit_to_unit % 10 == 0
906
+ Math.log10(currency.subunit_to_unit).to_s.to_i
907
+ else
908
+ Math.log10(currency.subunit_to_unit).to_s.to_i+1
909
+ end
904
910
  unit, subunit = cents.divmod(currency.subunit_to_unit).map{|o| o.to_s}
905
911
  return unit if decimal_places == 0
906
- subunit = (subunit + ("0" * decimal_places))[0, decimal_places]
912
+ subunit = (("0" * decimal_places) + subunit)[(-1*decimal_places)..-1]
907
913
  "#{unit}#{separator}#{subunit}"
908
914
  end
909
915
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 3
7
8
  - 5
8
- - 1
9
- version: 3.5.1
9
+ - 2
10
+ version: 3.5.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Tobias Luetke
@@ -29,6 +30,7 @@ dependencies:
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
33
+ hash: 3
32
34
  segments:
33
35
  - 0
34
36
  - 4
@@ -43,6 +45,7 @@ dependencies:
43
45
  requirements:
44
46
  - - ">="
45
47
  - !ruby/object:Gem::Version
48
+ hash: 15
46
49
  segments:
47
50
  - 2
48
51
  - 0
@@ -58,6 +61,7 @@ dependencies:
58
61
  requirements:
59
62
  - - ">="
60
63
  - !ruby/object:Gem::Version
64
+ hash: 3
61
65
  segments:
62
66
  - 0
63
67
  version: "0"
@@ -71,6 +75,7 @@ dependencies:
71
75
  requirements:
72
76
  - - ">="
73
77
  - !ruby/object:Gem::Version
78
+ hash: 3
74
79
  segments:
75
80
  - 0
76
81
  version: "0"
@@ -110,6 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
115
  requirements:
111
116
  - - ">="
112
117
  - !ruby/object:Gem::Version
118
+ hash: 3
113
119
  segments:
114
120
  - 0
115
121
  version: "0"
@@ -118,6 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
124
  requirements:
119
125
  - - ">="
120
126
  - !ruby/object:Gem::Version
127
+ hash: 23
121
128
  segments:
122
129
  - 1
123
130
  - 3