2011-02-20 22:01:28 -05:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
module Voxel
|
2011-02-20 22:01:28 -05:00
|
|
|
class VoxcloudStatus < Fog::Parsers::Base
|
|
|
|
def reset
|
2011-02-23 18:00:56 -05:00
|
|
|
@response = { 'devices' => [] }
|
2011-02-20 22:01:28 -05:00
|
|
|
@device = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
|
|
|
super
|
|
|
|
|
|
|
|
case name
|
|
|
|
when 'rsp'
|
2011-02-23 18:00:56 -05:00
|
|
|
@response['stat'] = attr_value('stat', attrs)
|
2011-02-20 22:01:28 -05:00
|
|
|
when 'err'
|
2011-02-23 18:00:56 -05:00
|
|
|
@response['err'] = {
|
|
|
|
'code' => attr_value('code', attrs),
|
|
|
|
'msg' => attr_value('msg', attrs)
|
|
|
|
}
|
2011-02-20 22:01:28 -05:00
|
|
|
when 'device'
|
|
|
|
@device = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
|
|
|
when 'device'
|
2011-02-23 18:00:56 -05:00
|
|
|
@response['devices'] << @device
|
2011-02-20 22:01:28 -05:00
|
|
|
@device = {}
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'id', 'status'
|
2011-05-12 16:15:13 -04:00
|
|
|
@device[name] = value
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'last_update'
|
2011-05-12 16:15:13 -04:00
|
|
|
@device[name] = Time.at(value.to_i)
|
2011-02-20 22:01:28 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|