Class: Evri::RPX::User
- Inherits:
-
Object
- Object
- Evri::RPX::User
- Defined in:
- lib/evri/rpx/user.rb
Defined Under Namespace
Classes: InvalidUserJsonError
Instance Attribute Summary (collapse)
-
- (Object) credentials
readonly
Returns a Credentials object for this user, or nil.
-
- (Object) json
(also: #raw)
readonly
Returns the raw JSON returned by RPX, in case you want it.
Instance Method Summary (collapse)
-
- (Object) display_name
Returns a name that should be displayed for this user.
-
- (Object) email
Returns a user's email.
-
- (Boolean) facebook?
Returns true if this is a Facebook login.
-
- (Boolean) google?
Returns true if this is a Google login.
-
- (Object) identifier
Returns a unique identifier for this user.
-
- (User) initialize(json)
constructor
A new instance of User.
-
- (Object) name
Returns the person's full name (aka David Balatero).
-
- (Object) photo
Returns a photo URL for a user if they have one.
-
- (Object) primary_key
Returns the primary key for this user, if they have been mapped already.
-
- (Object) profile_url
Returns a URL to a person's profile on the 3rd-party site.
-
- (Object) provider_name
Returns the provider name for this user, aka "Twitter", "Google".
-
- (Boolean) twitter?
Returns true if this is a Twitter login.
-
- (Object) username
Returns a username for this user.
-
- (Boolean) windows_live?
Returns true if this is a Windows Live login.
-
- (Boolean) yahoo?
Returns true if this is a Yahoo! login.
Constructor Details
- (User) initialize(json)
A new instance of User
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/evri/rpx/user.rb', line 13 def initialize(json) if json.nil? or !json['profile'] raise InvalidUserJsonError, 'The JSON passed in is invalid!' end @json = json if @json['accessCredentials'] @credentials = Credentials.new(@json['accessCredentials']) end end |
Instance Attribute Details
- (Object) credentials (readonly)
Returns a Credentials object for this user, or nil.
7 8 9 |
# File 'lib/evri/rpx/user.rb', line 7 def credentials @credentials end |
- (Object) json (readonly) Also known as: raw
Returns the raw JSON returned by RPX, in case you want it.
10 11 12 |
# File 'lib/evri/rpx/user.rb', line 10 def json @json end |
Instance Method Details
- (Object) display_name
Returns a name that should be displayed for this user.
32 33 34 |
# File 'lib/evri/rpx/user.rb', line 32 def display_name @json['profile']['displayName'] rescue nil end |
- (Object) email
Returns a user's email.
63 64 65 |
# File 'lib/evri/rpx/user.rb', line 63 def email @json['profile']['email'] rescue nil end |
- (Boolean) facebook?
Returns true if this is a Facebook login.
84 85 86 |
# File 'lib/evri/rpx/user.rb', line 84 def facebook? provider_name == 'Facebook' end |
- (Boolean) google?
Returns true if this is a Google login.
79 80 81 |
# File 'lib/evri/rpx/user.rb', line 79 def google? provider_name == 'Google' end |
- (Object) identifier
Returns a unique identifier for this user.
42 43 44 |
# File 'lib/evri/rpx/user.rb', line 42 def identifier @json['profile']['identifier'] rescue nil end |
- (Object) name
Returns the person's full name (aka David Balatero)
27 28 29 |
# File 'lib/evri/rpx/user.rb', line 27 def name @json['profile']['name']['formatted'] rescue nil end |
- (Object) photo
Returns a photo URL for a user if they have one.
53 54 55 |
# File 'lib/evri/rpx/user.rb', line 53 def photo @json['profile']['photo'] rescue nil end |
- (Object) primary_key
Returns the primary key for this user, if they have been mapped already.
48 49 50 |
# File 'lib/evri/rpx/user.rb', line 48 def primary_key @json['profile']['primaryKey'] rescue nil end |
- (Object) profile_url
Returns a URL to a person's profile on the 3rd-party site.
58 59 60 |
# File 'lib/evri/rpx/user.rb', line 58 def profile_url @json['profile']['url'] rescue nil end |
- (Object) provider_name
Returns the provider name for this user, aka "Twitter", "Google". Also, see convenience methods such as #google?, #twitter?
69 70 71 |
# File 'lib/evri/rpx/user.rb', line 69 def provider_name @json['profile']['providerName'] rescue nil end |
- (Boolean) twitter?
Returns true if this is a Twitter login.
74 75 76 |
# File 'lib/evri/rpx/user.rb', line 74 def twitter? provider_name == 'Twitter' end |
- (Object) username
Returns a username for this user.
37 38 39 |
# File 'lib/evri/rpx/user.rb', line 37 def username @json['profile']['preferredUsername'] rescue nil end |
- (Boolean) windows_live?
Returns true if this is a Windows Live login.
94 95 96 |
# File 'lib/evri/rpx/user.rb', line 94 def windows_live? provider_name == 'Windows Live' end |
- (Boolean) yahoo?
Returns true if this is a Yahoo! login.
89 90 91 |
# File 'lib/evri/rpx/user.rb', line 89 def yahoo? provider_name == 'Yahoo!' end |