money 2.1.2 → 2.1.3
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.
- data/lib/money/money.rb +9 -1
- data/money.gemspec +1 -1
- data/test/money_spec.rb +7 -0
- metadata +1 -1
data/lib/money/money.rb
CHANGED
@@ -169,7 +169,15 @@ class Money
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
|
172
|
+
if rules.has_key?(:symbol)
|
173
|
+
if rules[:symbol]
|
174
|
+
symbol = rules[:symbol]
|
175
|
+
else
|
176
|
+
symbol = ""
|
177
|
+
end
|
178
|
+
else
|
179
|
+
symbol = "$"
|
180
|
+
end
|
173
181
|
|
174
182
|
if rules[:no_cents]
|
175
183
|
formatted = sprintf("#{symbol}%d", cents.to_f / 100)
|
data/money.gemspec
CHANGED
data/test/money_spec.rb
CHANGED
@@ -131,6 +131,13 @@ describe Money do
|
|
131
131
|
Money.new(100, :currency => "GBP").format(:symbol => "£").should == "£1.00"
|
132
132
|
end
|
133
133
|
|
134
|
+
specify "#format with :symbol == "", nil or false returns the amount without a symbol" do
|
135
|
+
money = Money.new(100, :currency => "GBP")
|
136
|
+
money.format(:symbol => "").should == "1.00"
|
137
|
+
money.format(:symbol => nil).should == "1.00"
|
138
|
+
money.format(:symbol => false).should == "1.00"
|
139
|
+
end
|
140
|
+
|
134
141
|
specify "#format(:html => true) works as documented" do
|
135
142
|
string = Money.ca_dollar(570).format(:html => true, :with_currency => true)
|
136
143
|
string.should == "$5.70 <span class=\"currency\">CAD</span>"
|