class Reddit
Constants
- URL
Public Class Methods
random()
click to toggle source
# File lib/reddit.rb, line 8 def self.random w = WebPage.new URL doc = Nokogiri::HTML w.raw a = doc.xpath '//a[@class="title may-blank outbound "]' url = '' while url[0..3] != 'http' do i = Random.rand a.length title = a[i].text url = a[i]['href'] end return "#{title}\n#{url}" end