Class: GithubApi::FollowersPage
- Inherits:
-
Object
- Object
- GithubApi::FollowersPage
- Defined in:
- lib/unofficial-github-api/github_api.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #content ⇒ Object
- #follower_exists?(i) ⇒ Boolean
- #follower_name(i) ⇒ Object
- #follower_row(i) ⇒ Object
- #followers_list ⇒ Object
-
#initialize(user_name, page_number) ⇒ FollowersPage
constructor
A new instance of FollowersPage.
Constructor Details
#initialize(user_name, page_number) ⇒ FollowersPage
Returns a new instance of FollowersPage.
44 45 46 47 |
# File 'lib/unofficial-github-api/github_api.rb', line 44 def initialize(user_name, page_number) @name = user_name @page = page_number end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
43 44 45 |
# File 'lib/unofficial-github-api/github_api.rb', line 43 def name @name end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
43 44 45 |
# File 'lib/unofficial-github-api/github_api.rb', line 43 def page @page end |
Instance Method Details
#content ⇒ Object
49 50 51 |
# File 'lib/unofficial-github-api/github_api.rb', line 49 def content @content ||= Nokogiri::HTML(open("https://github.com/#{name}/followers?page=#{page}")) end |
#follower_exists?(i) ⇒ Boolean
61 62 63 |
# File 'lib/unofficial-github-api/github_api.rb', line 61 def follower_exists?(i) follower_row(i).to_ary != [] end |
#follower_name(i) ⇒ Object
57 58 59 |
# File 'lib/unofficial-github-api/github_api.rb', line 57 def follower_name(i) follower_row(i).children[1].attributes['href'].value.gsub(/\//,'') end |
#follower_row(i) ⇒ Object
53 54 55 |
# File 'lib/unofficial-github-api/github_api.rb', line 53 def follower_row(i) content.xpath("//*[@id='site-container']/div[2]/ol/li[#{i}]") end |
#followers_list ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/unofficial-github-api/github_api.rb', line 65 def followers_list i, list = 1, [] while follower_exists?(i) list << follower_name(i) i += 1 end list end |