Sha256: 6e7fdce22c9532f7474aa1bba78c6c00881645e521cee4a0a21feccbf23b7434

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

require 'eolclub_scraper/event'
require 'nokogiri'
require 'chronic'

module EolclubScraper

  class EventParser

    # This method is extremely fragile, but so far EOLclub.org has been sticking to
    # the same format, so that may be okay.
    def parse(content)
      doc = Nokogiri::HTML.parse(content)
      schedule_text = doc.css('p')[1].text.split("\n")[2].split(',').last.strip.split
      start_time, end_time = schedule_text.last.split('–')

      Event.new(
        Chronic.parse( [ schedule_text[0], schedule_text[1], start_time ].join(' ') ),
        Chronic.parse( [ schedule_text[0], schedule_text[1], end_time ].join(' ') )
      )
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eolclub_scraper-0.0.1 lib/eolclub_scraper/event_parser.rb