Class: ByteNumber
- Inherits:
-
Numeric
- Object
- Numeric
- ByteNumber
- Defined in:
- lib/vagrant-libvirt/util/byte_number.rb
Class Method Summary collapse
Instance Method Summary collapse
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #/(other) ⇒ Object
- #<=>(other) ⇒ Object
- #coerce(other) ⇒ Object
-
#initialize(int) ⇒ ByteNumber
constructor
A new instance of ByteNumber.
- #pow(n) ⇒ Object
- #to_B ⇒ Object
- #to_f ⇒ Object
- #to_GB ⇒ Object
- #to_i ⇒ Object
- #to_KB ⇒ Object
- #to_MB ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(int) ⇒ ByteNumber
Returns a new instance of ByteNumber.
2 3 4 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 2 def initialize(int) @int = int end |
Class Method Details
.from_GB(value) ⇒ Object
62 63 64 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 62 def self.from_GB(value) self.new(value*(1024**3)) end |
Instance Method Details
#*(other) ⇒ Object
50 51 52 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 50 def *(other) to_i * other end |
#+(other) ⇒ Object
42 43 44 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 42 def +(other) to_i + other end |
#-(other) ⇒ Object
46 47 48 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 46 def -(other) to_i - other end |
#/(other) ⇒ Object
54 55 56 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 54 def /(other) to_i / other end |
#<=>(other) ⇒ Object
38 39 40 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 38 def <=>(other) to_i <=> other end |
#coerce(other) ⇒ Object
34 35 36 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 34 def coerce(other) to_i.coerce(other) end |
#pow(n) ⇒ Object
58 59 60 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 58 def pow(n) self.class.new(to_i ** n) end |
#to_B ⇒ Object
18 19 20 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 18 def to_B to_i end |
#to_f ⇒ Object
14 15 16 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 14 def to_f @int.to_f end |
#to_GB ⇒ Object
30 31 32 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 30 def to_GB _compute_unit_to_n_kilo(3) end |
#to_i ⇒ Object
10 11 12 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 10 def to_i @int end |
#to_KB ⇒ Object
22 23 24 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 22 def to_KB _compute_unit_to_n_kilo(1) end |
#to_MB ⇒ Object
26 27 28 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 26 def to_MB _compute_unit_to_n_kilo(2) end |
#to_s ⇒ Object
6 7 8 |
# File 'lib/vagrant-libvirt/util/byte_number.rb', line 6 def to_s @int.to_s end |