Class: InTheNews::Parser
- Inherits:
-
Object
- Object
- InTheNews::Parser
- Defined in:
- lib/inthenews.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.
37 38 |
# File 'lib/inthenews.rb', line 37 def initialize end |
Instance Method Details
#content ⇒ Object
53 54 55 56 |
# File 'lib/inthenews.rb', line 53 def content RestClient.proxy = ENV['http_proxy'] @content ||= RestClient.get wikipedia_url end |
#doc ⇒ Object
45 46 47 |
# File 'lib/inthenews.rb', line 45 def doc Nokogiri::HTML(content) end |
#items ⇒ Object
40 41 42 43 |
# File 'lib/inthenews.rb', line 40 def items elements = doc.xpath("//div[@id='mp-itn']/ul/li") elements.map {|e| Item.new(e)} end |
#wikipedia_url ⇒ Object
49 50 51 |
# File 'lib/inthenews.rb', line 49 def wikipedia_url "http://en.wikipedia.org/wiki/Main_Page" end |