Class: Superavatar::Sources::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/superavatar/sources/github.rb

Instance Method Summary collapse

Constructor Details

#initialize(username) ⇒ Github



6
7
8
9
# File 'lib/superavatar/sources/github.rb', line 6

def initialize(username)
  @username = username
  @avatar_url = nil
end

Instance Method Details

#api_profile_endpointObject



23
24
25
# File 'lib/superavatar/sources/github.rb', line 23

def api_profile_endpoint
  "https://api.github.com/users/#{@username}"
end

#get_avatar_urlObject



11
12
13
14
15
16
17
# File 'lib/superavatar/sources/github.rb', line 11

def get_avatar_url
  return @avatar_url unless @avatar_url.nil?

  url = api_profile_endpoint
  github_res = Superavatar::Utils::Apiclient.fetch_external_api(url)
  @avatar_url = github_res.fetch('avatar_url')
end

#web_profileObject



19
20
21
# File 'lib/superavatar/sources/github.rb', line 19

def web_profile
  "https://github.com/#{@username}/"
end