Class: TreasureData::Account

Inherits:
Model
  • Object
show all
Defined in:
lib/td/client/model.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#client

Instance Method Summary collapse

Constructor Details

#initialize(client, account_id, plan, storage_size = nil, guaranteed_cores = nil, maximum_cores = nil, created_at = nil) ⇒ Account

Returns a new instance of Account.



14
15
16
17
18
19
20
21
22
# File 'lib/td/client/model.rb', line 14

def initialize(client, , plan, storage_size=nil, guaranteed_cores=nil, maximum_cores=nil, created_at=nil)
  super(client)
  @account_id = 
  @plan = plan
  @storage_size = storage_size
  @guaranteed_cores = guaranteed_cores
  @maximum_cores = maximum_cores
  @created_at = created_at
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



24
25
26
# File 'lib/td/client/model.rb', line 24

def 
  @account_id
end

#guaranteed_coresObject (readonly)

Returns the value of attribute guaranteed_cores.



24
25
26
# File 'lib/td/client/model.rb', line 24

def guaranteed_cores
  @guaranteed_cores
end

#maximum_coresObject (readonly)

Returns the value of attribute maximum_cores.



24
25
26
# File 'lib/td/client/model.rb', line 24

def maximum_cores
  @maximum_cores
end

#planObject (readonly)

Returns the value of attribute plan.



24
25
26
# File 'lib/td/client/model.rb', line 24

def plan
  @plan
end

#storage_sizeObject (readonly)

Returns the value of attribute storage_size.



24
25
26
# File 'lib/td/client/model.rb', line 24

def storage_size
  @storage_size
end

Instance Method Details

#created_atObject



26
27
28
# File 'lib/td/client/model.rb', line 26

def created_at
  @created_at && !@created_at.empty? ? Time.parse(@created_at) : nil
end

#storage_size_stringObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/td/client/model.rb', line 30

def storage_size_string
  if @storage_size <= 1024 * 1024
    return "0.0 GB"
  elsif @storage_size <= 60 * 1024 * 1024
    return "0.01 GB"
  elsif @storage_size <= 60 * 1024 * 1024 * 1024
    "%.1f GB" % (@storage_size.to_f / (1024 * 1024 * 1024))
  else
    "%d GB" % (@storage_size.to_f / (1024 * 1024 * 1024)).to_i
  end
end