Class: Humanize::Bytes::Mega

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

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Mega

Returns a new instance of Mega.



4
5
6
# File 'lib/humanize-bytes/mbyte.rb', line 4

def initialize(value)
  @value = value
end

Instance Method Details

#to_bObject



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

def to_b
  Byte.new @value * 1024 * 1024
end

#to_gObject



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

def to_g
  Giga.new @value / 1024.0
end

#to_kObject



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

def to_k
  Kilo.new @value * 1024
end

#to_mObject



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

def to_m
  self
end

#to_sObject



28
29
30
# File 'lib/humanize-bytes/mbyte.rb', line 28

def to_s
  @value.instance_of?(Float) ? formatted_float + ' mega bytes' : @value.to_s + ' mega bytes'
end

#valueObject



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

def value
  @value
end