Sha256: 95148405e66aee5c694f70599f2e93ed275dc542d791e890502766b67a8ce219

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

module Fog
  module Parsers
    module Voxel
      module Compute

        class ImagesList < Fog::Parsers::Base

          def reset
            @image = {}
            @response = { 'images' => [] }
          end

          def start_element(name, attrs = [])
            super

            case name
            when 'err'
              @response['err'] = {
                'code'  => attr_value('code', attrs),
                'msg'   => attr_value('msg', attrs)
              }
            when 'size'
              @image['filesystem']['units'] = attr_value('units', attrs)
            when 'image'
              @image = {
                'id' => attr_value('id', attrs).to_i,
                'summary' => attr_value('summary', attrs)
              }
            when 'filesystem', 'operating_system'
              @image[name] = {}
            when 'rsp'
              @response['stat'] = attr_value('stat', attrs)
            end
          end

          def end_element(name)
            case name
            when 'architecture'
              @image['operating_system'][name] = @value.to_i
            when 'admin_username', 'family', 'product_family', 'product_version', 'version'
              @image['operating_system'][name] = @value
            when 'description'
              @image[name] = @value
            when 'image'
              @response['images'] << @image
              @image = {}
            when 'size'
              @image['filesystem'][name] = @value.to_i
            when 'type'
              @image['filesystem'][name] = @value
            end
          end

        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-0.7.2 lib/fog/compute/parsers/voxel/images_list.rb
fog-0.7.1 lib/fog/compute/parsers/voxel/images_list.rb
fog-0.7.0 lib/fog/compute/parsers/voxel/images_list.rb
fog-0.6.0 lib/fog/compute/parsers/voxel/images_list.rb