Class: Brightbox::Account

Inherits:
Api
  • Object
show all
Defined in:
lib/bbcloud/accounts.rb

Instance Attribute Summary

Attributes inherited from Api

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api

cache_all!, cached_get, conn, #exists?, find, find_by_handle, #fog_model, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Brightbox::Api

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Brightbox::Api

Class Method Details

.allObject



14
15
16
17
18
# File 'lib/bbcloud/accounts.rb', line 14

def self.all
  a = conn.
  a.connection = conn
  [new(a)]
end

.default_field_orderObject



30
31
32
# File 'lib/bbcloud/accounts.rb', line 30

def self.default_field_order
  [:id, :name, :cloud_ip_limit, :ram_limit, :ram_used, :ram_free]
end

.get(id) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/bbcloud/accounts.rb', line 20

def self.get(id)
  a = conn.
  a.connection = conn
  if a.id == id
    new(a)
  else
    nil
  end
end

Instance Method Details

#ram_freeObject



4
5
6
# File 'lib/bbcloud/accounts.rb', line 4

def ram_free
  [ram_limit.to_i - ram_used.to_i, 0].max
end

#to_rowObject



8
9
10
11
12
# File 'lib/bbcloud/accounts.rb', line 8

def to_row
  attributes.merge({ :ram_free => ram_free, 
                     :cloud_ip_limit => limits_cloudips
                   })
end

#to_sObject



34
35
36
# File 'lib/bbcloud/accounts.rb', line 34

def to_s
  @id
end