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
Attributes inherited from WikiOnThisDay::Scraper
Instance Method Summary collapse
-
#initialize ⇒ Homepage
constructor
A new instance of Homepage.
- #on_this_day ⇒ Object
Constructor Details
#initialize ⇒ Homepage
Returns a new instance of Homepage.
3 4 5 |
# File 'lib/wiki_on_this_day/homepage.rb', line 3 def initialize super('https://en.wikipedia.org/wiki/Main_Page') end |
Instance Method Details
#on_this_day ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/wiki_on_this_day/homepage.rb', line 7 def on_this_day events_hash = {} self.html_doc.css('div#mp-otd div#mp-otd-img + ul li').each do |event| events_hash[event.css('b a').text] = {} events_hash[event.css('b a').text][:year] = event.css('a').first.text events_hash[event.css('b a').text][:text] = event.children.text.split(/ – /)[1] events_hash[event.css('b a').text][:link_url] = 'https://en.wikipedia.org' + event.css('b a')[0]["href"] end events_hash end |