Class: Fixnum
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#to_human_size(precision = 1) ⇒ Object
Lifted from Rails’ NumberHelper view helper.
Instance Method Details
#blank? ⇒ Boolean
24 25 26 |
# File 'lib/iron/extensions/fixnum.rb', line 24 def blank? false end |
#to_human_size(precision = 1) ⇒ Object
Lifted from Rails’ NumberHelper view helper
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/iron/extensions/fixnum.rb', line 4 def to_human_size(precision=1) size = Kernel.Float(self) case when size.to_i == 1 then "1 Byte" when size < 1024 then "#{size} Bytes" when size < 1024*1024 then "#{(size / 1024).to_display(precision)} KB" when size < 1024*1024*1024 then "#{(size / (1024*1024)).to_display(precision)} MB" when size < 1024*1024*1024*1024 then "#{(size / (1024*1024*1024)).to_display(precision)} GB" else "#{(size / (1024*1024*1024*1024)).to_display(precision)} GB" end rescue nil end |