Class: DF

Inherits:
Object
  • Object
show all
Includes:
RunCommand
Defined in:
lib/city_watch/commands/df.rb

Instance Method Summary collapse

Methods included from RunCommand

#command_line, #command_line_opts, #command_output, included, #options, #set_opts, #supported?

Instance Method Details

#dataObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/city_watch/commands/df.rb', line 7

def data
	headers = false
	output = []
	command_output.split("\n").map {|line| line.split("\s") }.each do |line|
		if !headers
			headers = line.map {|hdr| hdr.downcase.to_sym}
			headers.pop
			next
		end
		next unless headers
		pkt = {}
		line.each_with_index do |itm,idx|
			pkt[headers[idx]] = itm
		end
		output << pkt
	end
	output
end