kelredd-useful 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -144,13 +144,13 @@ module Useful
144
144
  # 1234567890.50.to_currency(:unit => "£", :separator => ",", :delimiter => "", :format => "%n %u")
145
145
  # # => 1234567890,50 £
146
146
  def to_currency(opts = {})
147
- return opts[:zero_display] if opts[:zero_display] && self == 0
147
+ return opts[:zero_display] if opts[:zero_display] && self.to_f == 0.to_f
148
148
  opts.symbolize_keys!
149
149
  opts[:locale] ||= :en
150
150
  locale = LOCALES[opts.delete(:locale)]
151
151
  opts = locale[:defaults].merge(locale[:format]).merge(locale[:currency]).merge(opts) unless locale.nil?
152
152
 
153
- opts[:format].gsub(/%n/, self.with_precision(opts.only(:precision, :delimiter, :separator))).gsub(/%u/, opts[:unit]) #rescue self
153
+ opts[:format].gsub(/%n/, self.with_precision(opts.only(:precision, :delimiter, :separator)).to_s).gsub(/%u/, opts[:unit].to_s) #rescue self
154
154
  end
155
155
 
156
156
  # Formats the bytes in +size+ into a more understandable representation
@@ -186,7 +186,7 @@ module Useful
186
186
  unit = ''
187
187
  STORAGE_UNITS.each do |storage_unit|
188
188
  unit = storage_unit.to_s.capitalize
189
- return opts[:format].gsub(/%n/, value.with_precision(opts.only(:precision, :delimiter, :separator))).gsub(/%u/, unit) if value < 1024 || storage_unit == STORAGE_UNITS.last
189
+ return opts[:format].gsub(/%n/, value.with_precision(opts.only(:precision, :delimiter, :separator)).to_s).gsub(/%u/, unit.to_s) if value < 1024 || storage_unit == STORAGE_UNITS.last
190
190
  value /= 1024.0
191
191
  end
192
192
  end
@@ -3,7 +3,7 @@ module Useful
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 7
6
+ TINY = 8
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-useful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelredd
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-18 00:00:00 -07:00
12
+ date: 2009-06-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15