Class: Xkcd
- Inherits:
-
Object
- Object
- Xkcd
- Defined in:
- lib/xkcd.rb
Constant Summary collapse
- URL =
'http://c.xkcd.com/random/comic/'
Class Method Summary collapse
Class Method Details
.random ⇒ Object
8 9 10 11 12 13 14 |
# 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 |