Class: XCPretty::GitHubInteractor

Inherits:
Object
  • Object
show all
Defined in:
lib/xcpretty/reporters/learn.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ GitHubInteractor

Returns a new instance of GitHubInteractor.



110
111
112
# File 'lib/xcpretty/reporters/learn.rb', line 110

def initialize(username)
  @username = username
end

Instance Attribute Details

#user_idObject (readonly)

Returns the value of attribute user_id.



104
105
106
# File 'lib/xcpretty/reporters/learn.rb', line 104

def user_id
  @user_id
end

#usernameObject (readonly)

Returns the value of attribute username.



104
105
106
# File 'lib/xcpretty/reporters/learn.rb', line 104

def username
  @username
end

Class Method Details

.get_user_id_for(username) ⇒ Object



106
107
108
# File 'lib/xcpretty/reporters/learn.rb', line 106

def self.get_user_id_for(username)
  new(username).get_user_id
end

Instance Method Details

#get_user_idObject



114
115
116
117
118
119
# File 'lib/xcpretty/reporters/learn.rb', line 114

def get_user_id
  @user_id ||= Oj.load(
    open("https://api.github.com/users/#{username}").read,
    symbol_keys: true
  )[:id]
end