lib/city_watch/commands/ps.rb in city-watch-0.3.0 vs lib/city_watch/commands/ps.rb in city-watch-0.3.1
- old
+ new
@@ -8,24 +8,22 @@
"aux"
end
def data
headers = false
- output = []
- command_output.split("\n").map {|line| line.split("\s") }.each do |line|
+ command_output.split("\n").map {|line| line.split("\s") }.inject([]) do |output,line|
if !headers
headers = line.map {|hdr| hdr.downcase.to_sym}
- next
+ else
+ pkt = {}
+ cmd = line.slice!(10,line.size-1)
+ line << cmd.join(" ")
+ line.each_with_index do |itm,idx|
+ pkt[headers[idx]] = itm
+ end
+ output << pkt
end
- next unless headers
- pkt = {}
- cmd = line.slice!(10,line.size-1)
- line << cmd.join(" ")
- line.each_with_index do |itm,idx|
- pkt[headers[idx]] = itm
- end
- output << pkt
+ output
end
- output
end
end
\ No newline at end of file