Class: Storcs::Parsers::DfNas

Inherits:
Object
  • Object
show all
Defined in:
lib/storcs/parsers/df_nas.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, file) ⇒ DfNas

Returns a new instance of DfNas.



5
6
7
8
# File 'lib/storcs/parsers/df_nas.rb', line 5

def initialize(name,file)
  @device = Storcs::Device.new(name)
  parse!(File.readlines(file))
end

Instance Attribute Details

#deviceObject

Returns the value of attribute device.



3
4
5
# File 'lib/storcs/parsers/df_nas.rb', line 3

def device
  @device
end

Instance Method Details

#parse!(content) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/storcs/parsers/df_nas.rb', line 10

def parse!(content)
  ary = content.map do |l|
    l.split(/\s+/)
  end.detect do |a|
    a[1] && a[1].match(/^\d+$/)
  end
  @device.real_size = ary[1].to_i * 1024
  @device.real_used = ary[2].to_i * 1024
end