Class: OnThisDay::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/onthisday.rb

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



58
59
# File 'lib/onthisday.rb', line 58

def initialize
end

Instance Method Details

#contentObject



74
75
76
77
# File 'lib/onthisday.rb', line 74

def content
  RestClient.proxy = ENV['http_proxy']
  @content ||= RestClient.get wikipedia_url
end

#docObject



66
67
68
# File 'lib/onthisday.rb', line 66

def doc
  Nokogiri::HTML(content)
end

#itemsObject



61
62
63
64
# File 'lib/onthisday.rb', line 61

def items
  elements = doc.xpath("//div[@id='mp-otd']/ul/li")
  elements.map {|e| Item.new(e)}
end

#wikipedia_urlObject



70
71
72
# File 'lib/onthisday.rb', line 70

def wikipedia_url
  "http://en.wikipedia.org/wiki/Main_Page"
end