Class: OnThisDay::Parser
- Inherits:
-
Object
- Object
- OnThisDay::Parser
- Defined in:
- lib/onthisday.rb
Instance Method Summary collapse
- #content ⇒ Object
- #doc ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #items ⇒ Object
- #wikipedia_url ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
58 59 |
# File 'lib/onthisday.rb', line 58 def initialize end |
Instance Method Details
#content ⇒ Object
74 75 76 77 |
# File 'lib/onthisday.rb', line 74 def content RestClient.proxy = ENV['http_proxy'] @content ||= RestClient.get wikipedia_url end |
#doc ⇒ Object
66 67 68 |
# File 'lib/onthisday.rb', line 66 def doc Nokogiri::HTML(content) end |
#items ⇒ Object
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_url ⇒ Object
70 71 72 |
# File 'lib/onthisday.rb', line 70 def wikipedia_url "http://en.wikipedia.org/wiki/Main_Page" end |