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:) ⇒ Developer

Returns a new instance of Developer.



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

def initialize(data:)
  @name = data['login']
  @id = data['id']
  @public_repos = data['public_repos']
end

Instance Attribute Details

#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

#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

Class Method Details

.find(username:) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/gitget/github_developer.rb', line 34

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

Instance Method Details

#reposObject



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

def repos
  return @repos if @repos

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