class NeinGag

Constants

URL

Public Class Methods

top() click to toggle source
# 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