Class: InTheNews::Parser

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

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



37
38
# File 'lib/inthenews.rb', line 37

def initialize
end

Instance Method Details

#contentObject



53
54
55
56
# File 'lib/inthenews.rb', line 53

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

#docObject



45
46
47
# File 'lib/inthenews.rb', line 45

def doc
  Nokogiri::HTML(content)
end

#itemsObject



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_urlObject



49
50
51
# File 'lib/inthenews.rb', line 49

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