Class: GithubInfo::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/github-info/github.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_name) ⇒ Github

Returns a new instance of Github.



7
8
9
10
11
12
13
14
# File 'lib/github-info/github.rb', line 7

def initialize(user_name)
  @user_name = user_name
  github_info = GithubInfo::Scraper.scrape(@user_name)
  @name = github_info[:user_info][:name]
  @contributions = github_info[:user_info][:contributions]
  @repositories = github_info[:repositories]
  @@all << self
end

Instance Attribute Details

#contributionsObject (readonly)

Returns the value of attribute contributions.



3
4
5
# File 'lib/github-info/github.rb', line 3

def contributions
  @contributions
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/github-info/github.rb', line 3

def name
  @name
end

#repositoriesObject (readonly)

Returns the value of attribute repositories.



3
4
5
# File 'lib/github-info/github.rb', line 3

def repositories
  @repositories
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



3
4
5
# File 'lib/github-info/github.rb', line 3

def user_name
  @user_name
end

Class Method Details

.allObject



25
26
27
# File 'lib/github-info/github.rb', line 25

def self.all
  return @@all
end

.find_or_create_by_user_name(user_name) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/github-info/github.rb', line 16

def self.find_or_create_by_user_name(user_name)
  @@all.each do |profile|
    if user_name == profile.user_name
      return profile
    end
  end
  return self.new(user_name)
end

Instance Method Details

#commit_history(index) ⇒ Object



29
30
31
# File 'lib/github-info/github.rb', line 29

def commit_history(index)
  return GithubInfo::Scraper.get_commit_history(@repositories[index][:href])
end