Sha256: f5e7872f4bd4c1eafdaf6af13528a462bfeb4f223dc1510bb69a461e0d826358

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

#
# Copyright (C) 2009  Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA


require 'dcloud/base_model'

module DCloud
    class Image < BaseModel

      xml_tag_name :image

      attribute :description
      attribute :owner_id
      attribute :architecture
      attribute :name

      def initialize(client, uri, xml=nil)
        super( client, uri, xml )
      end

      def load_payload(xml)
        super( xml )
        unless xml.nil?
          @description = xml.text( 'description' )
          @owner_id = xml.text( 'owner_id' )
          @name = xml.text( 'name' )
          @architecture = xml.text( 'architecture' )
        end
      end

      def to_plain
        sprintf("%-10s | %-20s | %-6s | %-20s | %15s",
          self.id[0,10],
          self.name ? self.name[0, 20]: 'unknown',
          self.architecture[0,6],
          self.description[0,20],
          self.owner_id[0,15]
        )
      end

    end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
deltacloud-client-0.0.4 lib/dcloud/image.rb
jcrossley-deltacloud-client-0.0.3.1 lib/dcloud/image.rb
deltacloud-client-0.0.3 lib/dcloud/image.rb