Class: LearnTest::GithubInteractor
- Inherits:
-
Object
- Object
- LearnTest::GithubInteractor
- Defined in:
- lib/learn_test/github_interactor.rb
Instance Attribute Summary collapse
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #get_user_id ⇒ Object
-
#initialize(username) ⇒ GithubInteractor
constructor
A new instance of GithubInteractor.
Constructor Details
#initialize(username) ⇒ GithubInteractor
Returns a new instance of GithubInteractor.
11 12 13 |
# File 'lib/learn_test/github_interactor.rb', line 11 def initialize(username) @username = username end |
Instance Attribute Details
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
5 6 7 |
# File 'lib/learn_test/github_interactor.rb', line 5 def user_id @user_id end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
5 6 7 |
# File 'lib/learn_test/github_interactor.rb', line 5 def username @username end |
Class Method Details
.get_user_id_for(username) ⇒ Object
7 8 9 |
# File 'lib/learn_test/github_interactor.rb', line 7 def self.get_user_id_for(username) new(username).get_user_id end |
Instance Method Details
#get_user_id ⇒ Object
15 16 17 18 19 20 |
# File 'lib/learn_test/github_interactor.rb', line 15 def get_user_id @user_id ||= Oj.load( open("https://api.github.com/users/#{username}").read, symbol_keys: true )[:id] end |