Class: Fog::Parsers::Compute::Voxel::VoxcloudStatus

Inherits:
Base
  • Object
show all
Defined in:
lib/rackspace-fog/voxel/parsers/compute/voxcloud_status.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#attr_value, #characters, #initialize, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rackspace-fog/voxel/parsers/compute/voxcloud_status.rb', line 27

def end_element(name)
  case name
  when 'device'
    @response['devices'] << @device
    @device = {}
  when 'id', 'status'
    @device[name] = value
  when 'last_update'
    @device[name] = Time.at(value.to_i)
  end
end

#resetObject



6
7
8
9
# File 'lib/rackspace-fog/voxel/parsers/compute/voxcloud_status.rb', line 6

def reset
  @response = { 'devices' => [] }
  @device = {}
end

#start_element(name, attrs = []) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rackspace-fog/voxel/parsers/compute/voxcloud_status.rb', line 11

def start_element(name, attrs = [])
  super

  case name
  when 'rsp'
    @response['stat'] = attr_value('stat', attrs)
  when 'err'
    @response['err'] = {
      'code'  => attr_value('code', attrs),
      'msg'   => attr_value('msg', attrs)
    }
  when 'device'
    @device = {}
  end
end