Class: CloudFS::Account
- Inherits:
-
Object
- Object
- CloudFS::Account
- Defined in:
- lib/cloudfs/account.rb
Overview
Account class defines properties of the end-user's CloudFS paid account
Instance Attribute Summary collapse
-
#account_locale ⇒ String
readonly
Locale of the entire account.
-
#id ⇒ String
readonly
Id of this user's account.
-
#over_storage_limit ⇒ Boolean
readonly
Whether user is currently over its storage quota.
-
#plan_display_name ⇒ String
readonly
Human readable name of account's CloudFS plan.
-
#plan_id ⇒ String
readonly
Id of CloudFS plan.
-
#session_locale ⇒ String
readonly
Locale of current session.
-
#state_display_name ⇒ String
readonly
Human readable name of account's CloudFS state.
-
#state_id ⇒ String
readonly
Id of current account state.
-
#storage_limit ⇒ Fixnum
readonly
Storage limit of account in bytes.
-
#storage_usage ⇒ Fixnum
readonly
Current storage usage of account in bytes.
Instance Method Summary collapse
-
#initialize(rest_adapter, **properties) ⇒ Account
constructor
A new instance of Account.
-
#refresh ⇒ Account
Refresh this user's account metadata from server.
Constructor Details
#initialize(rest_adapter, **properties) ⇒ Account
Returns a new instance of Account.
71 72 73 74 75 76 77 |
# File 'lib/cloudfs/account.rb', line 71
def initialize(rest_adapter, ** properties)
fail RestAdapter::Errors::ArgumentError,
"invalid RestAdapter type #{rest_adapter.class}, expected CloudFS::RestAdapter" unless rest_adapter.is_a?(CloudFS::RestAdapter)
@rest_adapter = rest_adapter
set_account_info(** properties)
end
|
Instance Attribute Details
#account_locale ⇒ String (readonly)
Returns locale of the entire account.
65 66 67 |
# File 'lib/cloudfs/account.rb', line 65
def account_locale
@properties[:locale]
end
|
#id ⇒ String (readonly)
Returns id of this user's account.
11 12 13 |
# File 'lib/cloudfs/account.rb', line 11
def id
@properties[:id]
end
|
#over_storage_limit ⇒ Boolean (readonly)
Returns whether user is currently over its storage quota.
29 30 31 |
# File 'lib/cloudfs/account.rb', line 29
def over_storage_limit
@properties[:storage][:otl]
end
|
#plan_display_name ⇒ String (readonly)
Returns Human readable name of account's CloudFS plan.
47 48 49 |
# File 'lib/cloudfs/account.rb', line 47
def plan_display_name
@properties[:account_plan][:display_name]
end
|
#plan_id ⇒ String (readonly)
Returns id of CloudFS plan.
53 54 55 |
# File 'lib/cloudfs/account.rb', line 53
def plan_id
@properties[:account_plan][:id]
end
|
#session_locale ⇒ String (readonly)
Returns locale of current session.
59 60 61 |
# File 'lib/cloudfs/account.rb', line 59
def session_locale
@properties[:session][:locale]
end
|
#state_display_name ⇒ String (readonly)
Returns Human readable name of account's CloudFS state.
41 42 43 |
# File 'lib/cloudfs/account.rb', line 41
def state_display_name
@properties[:account_state][:display_name]
end
|
#state_id ⇒ String (readonly)
Returns id of current account state.
35 36 37 |
# File 'lib/cloudfs/account.rb', line 35
def state_id
@properties[:account_state][:id]
end
|
#storage_limit ⇒ Fixnum (readonly)
Returns storage limit of account in bytes.
23 24 25 |
# File 'lib/cloudfs/account.rb', line 23
def storage_limit
@properties[:storage][:limit]
end
|
#storage_usage ⇒ Fixnum (readonly)
Returns current storage usage of account in bytes.
17 18 19 |
# File 'lib/cloudfs/account.rb', line 17
def storage_usage
@properties[:storage][:usage]
end
|
Instance Method Details
#refresh ⇒ Account
Refresh this user's account metadata from server
87 88 89 90 91 |
# File 'lib/cloudfs/account.rb', line 87
def refresh
response = @rest_adapter.get_profile
set_account_info(** response)
self
end
|