Class: Humanize::Bytes::Kilo

Inherits:
Object
  • Object
show all
Defined in:
lib/humanize-bytes/kbyte.rb

Instance Method Summary collapse

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_bObject



12
13
14
# File 'lib/humanize-bytes/kbyte.rb', line 12

def to_b
  Byte.new @value * 1024
end

#to_gObject



24
25
26
# File 'lib/humanize-bytes/kbyte.rb', line 24

def to_g
  Giga.new @value / 1024.0 / 1024
end

#to_kObject



16
17
18
# File 'lib/humanize-bytes/kbyte.rb', line 16

def to_k
  self
end

#to_mObject



20
21
22
# File 'lib/humanize-bytes/kbyte.rb', line 20

def to_m
  Mega.new @value / 1024.0
end

#to_sObject



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

#valueObject



8
9
10
# File 'lib/humanize-bytes/kbyte.rb', line 8

def value
  @value
end