Class: GithubInfo::Github
- Inherits:
-
Object
- Object
- GithubInfo::Github
- Defined in:
- lib/github-info/github.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#contributions ⇒ Object
readonly
Returns the value of attribute contributions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repositories ⇒ Object
readonly
Returns the value of attribute repositories.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Class Method Summary collapse
Instance Method Summary collapse
- #commit_history(index) ⇒ Object
-
#initialize(user_name) ⇒ Github
constructor
A new instance of Github.
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
#contributions ⇒ Object (readonly)
Returns the value of attribute contributions.
3 4 5 |
# File 'lib/github-info/github.rb', line 3 def contributions @contributions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/github-info/github.rb', line 3 def name @name end |
#repositories ⇒ Object (readonly)
Returns the value of attribute repositories.
3 4 5 |
# File 'lib/github-info/github.rb', line 3 def repositories @repositories end |
#user_name ⇒ Object (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
.all ⇒ Object
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 |