Class: Storcs::Device
- Inherits:
-
Object
- Object
- Storcs::Device
- Extended by:
- SummableSizes
- Defined in:
- lib/storcs/device.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#name ⇒ Object
Returns the value of attribute name.
-
#raid ⇒ Object
Returns the value of attribute raid.
Instance Method Summary collapse
- #free ⇒ Object
-
#initialize(name) ⇒ Device
constructor
A new instance of Device.
- #percent_free ⇒ Object
- #percent_used ⇒ Object
Methods included from SummableSizes
Constructor Details
#initialize(name) ⇒ Device
Returns a new instance of Device.
8 9 10 11 |
# File 'lib/storcs/device.rb', line 8 def initialize(name) @name = name @children = [] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
5 6 7 |
# File 'lib/storcs/device.rb', line 5 def children @children end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/storcs/device.rb', line 5 def name @name end |
#raid ⇒ Object
Returns the value of attribute raid.
5 6 7 |
# File 'lib/storcs/device.rb', line 5 def raid @raid end |
Instance Method Details
#free ⇒ Object
13 14 15 |
# File 'lib/storcs/device.rb', line 13 def free size - used end |
#percent_free ⇒ Object
22 23 24 25 |
# File 'lib/storcs/device.rb', line 22 def percent_free return 0 unless size.integer? && size > 0 (100 * free.to_f / size).round(2) end |
#percent_used ⇒ Object
17 18 19 20 |
# File 'lib/storcs/device.rb', line 17 def percent_used return 0 unless size.integer? && size > 0 (100 * used.to_f / size).round(2) end |