Class: WikiOnThisDay::Scraper::Homepage
- Inherits:
-
WikiOnThisDay::Scraper
- Object
- WikiOnThisDay::Scraper
- WikiOnThisDay::Scraper::Homepage
- Defined in:
- lib/wiki_on_this_day/homepage.rb
Instance Attribute Summary collapse
-
#snippets ⇒ Object
Returns the value of attribute snippets.
Attributes inherited from WikiOnThisDay::Scraper
Instance Method Summary collapse
-
#initialize ⇒ Homepage
constructor
A new instance of Homepage.
- #summarize ⇒ Object
Constructor Details
#initialize ⇒ Homepage
Returns a new instance of Homepage.
5 6 7 8 9 10 11 |
# File 'lib/wiki_on_this_day/homepage.rb', line 5 def initialize super('https://en.wikipedia.org/wiki/Main_Page') @snippets = Array.new self.html_doc.search('div#mp-otd div#mp-otd-img + ul li').each do |event| @snippets << WikiOnThisDay::Snippet.new(year: event.css('a').first.text, text: event.children.text.split(/ – /)[1], link_url: 'https://en.wikipedia.org' + event.css('b a')[0]["href"]) end end |
Instance Attribute Details
#snippets ⇒ Object
Returns the value of attribute snippets.
3 4 5 |
# File 'lib/wiki_on_this_day/homepage.rb', line 3 def snippets @snippets end |
Instance Method Details
#summarize ⇒ Object
13 14 15 |
# File 'lib/wiki_on_this_day/homepage.rb', line 13 def summarize self.snippets.each { |snippet| snippet.print } end |