lib/humanize/kilo.rb in humanize-bytes-2.0.0 vs lib/humanize/kilo.rb in humanize-bytes-2.0.1
- old
+ new
@@ -23,10 +23,11 @@
def to_g
Giga.new @value / 1024.0 / 1024
end
def to_s(options = {})
- size = options.fetch(:decimal_digits, value.to_s.size)
- ("%.#{size}f" % value).to_f
+ size = options.fetch(:decimal_digits, nil)
+ size ||= value.to_s.split('.').size == 1 ? 0 : value.to_s.split('.').last.size
+ ("%.#{size}f" % value).to_s
end
end
end
\ No newline at end of file