Class: DCloud::Realm

Inherits:
BaseModel show all
Defined in:
lib/dcloud/realm.rb

Instance Attribute Summary

Attributes inherited from BaseModel

#uri

Instance Method Summary collapse

Methods inherited from BaseModel

attribute, build_reader, #id, xml_tag_name

Constructor Details

#initialize(client, uri, xml = nil) ⇒ Realm

Returns a new instance of Realm.



29
30
31
# File 'lib/dcloud/realm.rb', line 29

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

Instance Method Details

#load_payload(xml = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dcloud/realm.rb', line 33

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

#to_plainObject



47
48
49
50
51
52
53
54
# File 'lib/dcloud/realm.rb', line 47

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