Sha256: 9ed1915e3dfd06f1752e84e3b44c9ee34207744f2fb429874da555a6e737938d

Contents?: true

Size: 908 Bytes

Versions: 8

Compression:

Stored size: 908 Bytes

Contents

module Brightbox
  class Account < Api

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

    def cloud_ip_limit
      attributes[:cloud_ips_limit]
    end

    def lb_limit
      attributes[:load_balancers_limit]
    end

    def to_row
      attributes.merge(:ram_free => ram_free, :cloud_ip_limit => cloud_ip_limit, :lb_limit => lb_limit)
    end

    def self.all
      a = conn.account
      a.connection = conn
      [a]
    end

    # The account associated with this connection
    def self.conn_account
      a = conn.account
      a.connection = conn
      a
    end

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

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

    def to_s
      @id
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/accounts.rb
brightbox-cli-0.18.0 lib/brightbox-cli/accounts.rb
brightbox-cli-0.17.5 lib/brightbox-cli/accounts.rb
brightbox-cli-0.17.4 lib/brightbox-cli/accounts.rb
brightbox-cli-0.17.3 lib/brightbox-cli/accounts.rb
brightbox-cli-0.17.2 lib/brightbox-cli/accounts.rb
brightbox-cli-0.17.1 lib/brightbox-cli/accounts.rb
brightbox-cli-0.17.0 lib/brightbox-cli/accounts.rb