Class: NeinGag
- Inherits:
-
Object
- Object
- NeinGag
- Defined in:
- lib/nein_gag.rb
Constant Summary collapse
- URL =
'http://www.9gag.com/'
Class Method Summary collapse
Class Method Details
.top ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nein_gag.rb', line 8 def self.top w = WebPage.new URL doc = Nokogiri::HTML w.raw posts = doc.xpath('//a[@class="badge-evt point"]').map do |a| { url: "http://www.9gag.com#{a['href']}", points: a.first_element_child.text.sub(/,/, '').to_i } end posts.sort! { |x,y| y[:points] - x[:points] } return posts.first[:url] end |