Class: Storcs::Device

Inherits:
Object
  • Object
show all
Extended by:
SummableSizes
Defined in:
lib/storcs/device.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SummableSizes

summable_sizes

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

#childrenObject

Returns the value of attribute children.



5
6
7
# File 'lib/storcs/device.rb', line 5

def children
  @children
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/storcs/device.rb', line 5

def name
  @name
end

#raidObject

Returns the value of attribute raid.



5
6
7
# File 'lib/storcs/device.rb', line 5

def raid
  @raid
end

Instance Method Details

#freeObject



13
14
15
# File 'lib/storcs/device.rb', line 13

def free
  size - used
end

#percent_freeObject



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_usedObject



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