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.

Parameters:

  • client (TreasureData::Client)
  • account_id (String)
  • plan (Fixnum)
  • storage_size (Fixnum) (defaults to: nil)
  • guaranteed_cores (Fixnum) (defaults to: nil)
  • maximum_cores (Fixnum) (defaults to: nil)
  • created_at (String) (defaults to: nil)


24
25
26
27
28
29
30
31
32
# File 'lib/td/client/model.rb', line 24

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)



39
40
41
# File 'lib/td/client/model.rb', line 39

def 
  @account_id
end

#guaranteed_coresObject (readonly)



39
# File 'lib/td/client/model.rb', line 39

attr_reader :account_id, :plan, :storage_size, :guaranteed_cores, :maximum_cores

#maximum_coresObject (readonly)

Returns the value of attribute maximum_cores.



39
# File 'lib/td/client/model.rb', line 39

attr_reader :account_id, :plan, :storage_size, :guaranteed_cores, :maximum_cores

#planObject (readonly)



39
# File 'lib/td/client/model.rb', line 39

attr_reader :account_id, :plan, :storage_size, :guaranteed_cores, :maximum_cores

#storage_sizeObject (readonly)



39
# File 'lib/td/client/model.rb', line 39

attr_reader :account_id, :plan, :storage_size, :guaranteed_cores, :maximum_cores

Instance Method Details

#created_atTime?

Returns:

  • (Time, nil)


42
43
44
# File 'lib/td/client/model.rb', line 42

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

#storage_size_stringString

Returns:

  • (String)


47
48
49
50
51
52
53
54
55
56
57
# File 'lib/td/client/model.rb', line 47

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