spook_and_puff_money 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/spook_and_puff/money.rb +5 -5
  2. metadata +2 -2
@@ -199,11 +199,11 @@ module SpookAndPuff
199
199
  # @option opts [true, false] :prefix
200
200
  # @return String
201
201
  def to_s(opts = {})
202
- if opts.has_key?(:prefix) and opts[:prefix] == false
203
- "%.2f" % @raw.round(2)
204
- else
205
- "$%.2f" % @raw.round(2)
206
- end
202
+ rounded = @raw.round(2)
203
+ prefix = opts[:prefix] == false ? '' : '$'
204
+ format = (opts[:drop_cents] and rounded == @raw.round) ? "%i" : "%.2f"
205
+
206
+ "#{prefix}#{format}" % rounded
207
207
  end
208
208
 
209
209
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spook_and_puff_money
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-10-27 00:00:00.000000000 Z
13
+ date: 2013-10-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec