Class: Github::Developer

Inherits:
Object
  • Object
show all
Defined in:
lib/gitget/github_developer.rb

Overview

Main class to set up a Github User

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data: nil) ⇒ Developer

Returns a new instance of Developer.



9
10
11
# File 'lib/gitget/github_developer.rb', line 9

def initialize(data: nil)
  load_data(data)
end

Instance Attribute Details

#avatar_urlObject (readonly)

Returns the value of attribute avatar_url.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def avatar_url
  @avatar_url
end

#bioObject (readonly)

Returns the value of attribute bio.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def bio
  @bio
end

#blogObject (readonly)

Returns the value of attribute blog.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def blog
  @blog
end

#companyObject (readonly)

Returns the value of attribute company.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def company
  @company
end

#emailObject (readonly)

Returns the value of attribute email.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def email
  @email
end

#followersObject (readonly)

Returns the value of attribute followers.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def followers
  @followers
end

#followingObject (readonly)

Returns the value of attribute following.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def following
  @following
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def id
  @id
end

#locationObject (readonly)

Returns the value of attribute location.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def name
  @name
end

#public_reposObject (readonly)

Returns the value of attribute public_repos.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def public_repos
  @public_repos
end

#usernameObject (readonly)

Returns the value of attribute username.



6
7
8
# File 'lib/gitget/github_developer.rb', line 6

def username
  @username
end

Class Method Details

.find(username:) ⇒ Object



52
53
54
55
56
# File 'lib/gitget/github_developer.rb', line 52

def self.find(username:)
  user_data = Github::API.(username)
  return nil if user_data['message'] == 'Not Found'
  new(data: user_data)
end

Instance Method Details

#load_data(repo_data) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gitget/github_developer.rb', line 39

def load_data(repo_data)
  @username = repo_data['login']
  @id = repo_data['id']
  @public_repos = repo_data['public_repos']
  @avatar_url = repo_data['avatar_url']
  @name = repo_data['name']
  @company = repo_data['company']
  @blog = repo_data['blog']
  @location = repo_data['location']
  @email = repo_data['email']
  @bio = repo_data['bio']
end

#reposObject



13
14
15
16
17
18
19
# File 'lib/gitget/github_developer.rb', line 13

def repos
  return @repos if @repos

  @repos = Github::API.user_repos(@username).map do |repo_data|
    Github::Repository.new(data: repo_data)
  end
end

#starredObject



33
34
35
36
37
# File 'lib/gitget/github_developer.rb', line 33

def starred
  return @starred if @starred

  @starred = Github::API.user_starred @username
end