Class: EolclubScraper::EventParser

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

Instance Method Summary collapse

Instance Method Details

#parse(content) ⇒ Object

This method is extremely fragile, but so far EOLclub.org has been sticking to the same format, so that may be okay.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/eolclub_scraper/event_parser.rb', line 10

def parse(content)
  doc = Nokogiri::HTML.parse(content)
  description = doc.css('p').first(3).map(&:to_html).join

  start_time = doc.css('abbr.dtstart').first.attributes['title'].value
  end_time = doc.css('abbr.dtend').first.attributes['title'].value

  Event.new(
    Time.parse(start_time),
    Time.parse(end_time),
    description
  )
end