Class: CloudFS::User
- Inherits:
-
Object
- Object
- CloudFS::User
- Defined in:
- lib/cloudfs/user.rb
Overview
User class maintains user profile information
Instance Attribute Summary collapse
-
#created_at ⇒ Time
readonly
Account creation time.
-
#email ⇒ String
readonly
Email id of user.
-
#first_name ⇒ String
readonly
First name of user.
-
#id ⇒ String
readonly
Internal id of user.
-
#last_login ⇒ Time
readonly
Last login time.
-
#last_name ⇒ String
readonly
Last name of user.
-
#username ⇒ String
readonly
End-user's username.
Instance Method Summary collapse
-
#initialize(rest_adapter, **properties) ⇒ User
constructor
A new instance of User.
-
#refresh ⇒ User
Refresh this user's metadata from server.
Constructor Details
#initialize(rest_adapter, **properties) ⇒ User
Returns a new instance of User.
68 69 70 71 72 73 74 |
# File 'lib/cloudfs/user.rb', line 68
def initialize(rest_adapter, ** properties)
fail RestAdapter::Errors::ArgumentError,
"invalid rest_adapter type #{rest_adapter.class}, expected CloudFS::Client" unless rest_adapter.is_a?(CloudFS::RestAdapter)
@rest_adapter = rest_adapter
set_user_info(** properties)
end
|
Instance Attribute Details
#created_at ⇒ Time (readonly)
Returns account creation time.
41 42 43 44 45 46 47 |
# File 'lib/cloudfs/user.rb', line 41
def created_at
if @properties[:created_at]
Time.at(@properties[:created_at]/1000.0)
else
nil
end
end
|
#email ⇒ String (readonly)
Returns email id of user.
35 36 37 |
# File 'lib/cloudfs/user.rb', line 35
def email
@properties[:email]
end
|
#first_name ⇒ String (readonly)
Returns first name of user.
23 24 25 |
# File 'lib/cloudfs/user.rb', line 23
def first_name
@properties[:first_name]
end
|
#id ⇒ String (readonly)
Returns internal id of user.
11 12 13 |
# File 'lib/cloudfs/user.rb', line 11
def id
@properties[:id]
end
|
#last_login ⇒ Time (readonly)
Returns last login time.
51 52 53 54 55 56 57 |
# File 'lib/cloudfs/user.rb', line 51
def last_login
if @properties[:last_login]
Time.at(@properties[:last_login]/1000.0)
else
nil
end
end
|
#last_name ⇒ String (readonly)
Returns last name of user.
29 30 31 |
# File 'lib/cloudfs/user.rb', line 29
def last_name
@properties[:last_name]
end
|
#username ⇒ String (readonly)
Returns end-user's username.
17 18 19 |
# File 'lib/cloudfs/user.rb', line 17
def username
@properties[:username]
end
|
Instance Method Details
#refresh ⇒ User
Refresh this user's metadata from server
88 89 90 91 92 |
# File 'lib/cloudfs/user.rb', line 88
def refresh
response = @rest_adapter.get_profile
set_user_info(** response)
self
end
|