Sha256: 7863edba807e78fc4348333ea0cb6ad935f580af9e7103532f995f1c8775801b

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 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 Realm < BaseModel

      xml_tag_name :realm

      attribute :name
      attribute :state
      attribute :limit

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

      def load_payload(xml=nil)
        super(xml)
        unless xml.nil?
          @name = xml.text( 'name' )
          @state = xml.text( 'state' )
          @limit = xml.text( 'limit' )
          if ( @limit.nil? || @limit == '' )
            @limit = :unlimited
          else
            @limit = @limit.to_f
          end
        end
      end

      def to_plain
        sprintf("%-10s | %-15s | %-5s | %10s GB",
          self.id[0, 10],
          self.name[0, 15],
          self.state[0,5],
          self.limit.to_s[0,10]
        )
      end

    end
end

Version data entries

3 entries across 3 versions & 2 rubygems

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