class Xkcd
Constants
- URL
Public Class Methods
random()
click to toggle source
# File lib/xkcd.rb, line 8 def self.random w = WebPage.new URL doc = Nokogiri::HTML w.raw title = doc.xpath('//div[@id="ctitle"]').text url = w.raw.match(/Permanent link to this comic: (http:\/\/xkcd.com\/[0-9]+\/)/)[1] return "#{title}\n#{url}" end