Class: LearnWeb::Client::User::Me
- Inherits:
-
Object
- Object
- LearnWeb::Client::User::Me
- Includes:
- AttributePopulatable
- Defined in:
- lib/learn_web/client/user/me.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#full_name ⇒ Object
Returns the value of attribute full_name.
-
#github_gravatar ⇒ Object
Returns the value of attribute github_gravatar.
-
#github_uid ⇒ Object
Returns the value of attribute github_uid.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#response ⇒ Object
Returns the value of attribute response.
-
#silent_output ⇒ Object
Returns the value of attribute silent_output.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(response, silent_output: false) ⇒ Me
constructor
A new instance of Me.
- #parse! ⇒ Object
Methods included from AttributePopulatable
Constructor Details
#initialize(response, silent_output: false) ⇒ Me
Returns a new instance of Me.
11 12 13 14 15 16 |
# File 'lib/learn_web/client/user/me.rb', line 11 def initialize(response, silent_output: false) @response = response @silent_output = silent_output parse! end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def data @data end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def first_name @first_name end |
#full_name ⇒ Object
Returns the value of attribute full_name.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def full_name @full_name end |
#github_gravatar ⇒ Object
Returns the value of attribute github_gravatar.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def github_gravatar @github_gravatar end |
#github_uid ⇒ Object
Returns the value of attribute github_uid.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def github_uid @github_uid end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def id @id end |
#last_name ⇒ Object
Returns the value of attribute last_name.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def last_name @last_name end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def response @response end |
#silent_output ⇒ Object
Returns the value of attribute silent_output.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def silent_output @silent_output end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/learn_web/client/user/me.rb', line 5 def username @username end |
Instance Method Details
#parse! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/learn_web/client/user/me.rb', line 18 def parse! if response.status == 200 self.data = Oj.load(response.body, symbol_keys: true) populate_attributes! elsif silent_output == false case response.status when 401 puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset" exit 1 when 500 puts "Something went wrong. Please try again." exit 1 else puts "Something went wrong. Please try again." exit 1 end end self end |