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.
- data/lib/useful/ruby_extensions/numeric.rb +3 -3
- data/lib/useful/version.rb +1 -1
- metadata +2 -2
@@ -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
|
data/lib/useful/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2009-06-19 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|