Class: Humanize::Bytes::Kilo
- Inherits:
-
Object
- Object
- Humanize::Bytes::Kilo
- Defined in:
- lib/humanize-bytes/kbyte.rb
Instance Method Summary collapse
-
#initialize(value) ⇒ Kilo
constructor
A new instance of Kilo.
- #to_b ⇒ Object
- #to_g ⇒ Object
- #to_k ⇒ Object
- #to_m ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(value) ⇒ Kilo
Returns a new instance of Kilo.
4 5 6 |
# File 'lib/humanize-bytes/kbyte.rb', line 4 def initialize(value) @value = value end |
Instance Method Details
#to_b ⇒ Object
12 13 14 |
# File 'lib/humanize-bytes/kbyte.rb', line 12 def to_b Byte.new @value * 1024 end |
#to_g ⇒ Object
24 25 26 |
# File 'lib/humanize-bytes/kbyte.rb', line 24 def to_g Giga.new @value / 1024.0 / 1024 end |
#to_k ⇒ Object
16 17 18 |
# File 'lib/humanize-bytes/kbyte.rb', line 16 def to_k self end |
#to_m ⇒ Object
20 21 22 |
# File 'lib/humanize-bytes/kbyte.rb', line 20 def to_m Mega.new @value / 1024.0 end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/humanize-bytes/kbyte.rb', line 28 def to_s @value.instance_of?(Float) ? formatted_float + ' kilo bytes' : @value.to_s + ' kilo bytes' end |
#value ⇒ Object
8 9 10 |
# File 'lib/humanize-bytes/kbyte.rb', line 8 def value @value end |