Class: Storcs::Parsers::Nss
- Inherits:
-
Object
- Object
- Storcs::Parsers::Nss
- Includes:
- Utils
- Defined in:
- lib/storcs/parsers/nss.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
Instance Method Summary collapse
-
#initialize(name, file) ⇒ Nss
constructor
A new instance of Nss.
- #parse!(content) ⇒ Object
- #pools ⇒ Object
Methods included from Utils
Constructor Details
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/storcs/parsers/nss.rb', line 5 def device @device end |
Instance Method Details
#parse!(content) ⇒ Object
13 14 15 |
# File 'lib/storcs/parsers/nss.rb', line 13 def parse!(content) @device.children = pools end |
#pools ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/storcs/parsers/nss.rb', line 17 def pools return @pools if @pools @pools = [] current_allocated = nil @lines.each do |line| if line =~ /^Total (Available|Allocated) Space in "([^"]*)" \(ID: \d+\): (.*) MB/ size = $3.tr(',', '').to_i * 1024 * 1024 case $1 when 'Allocated' current_allocated = size when 'Available' current_available = size @pools << Storcs::Device.new($2) @pools.last.real_size = current_allocated + current_available @pools.last.real_used = current_allocated current_allocated = nil end end end @pools end |