Class: HolidayScraper::Parser

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

Defined Under Namespace

Classes: Event

Constant Summary collapse

DATE_PATTERN =
/[^,]+, (\d\d?. [^ ]+)(?: - [^,]+, (\d\d?. [^ ]+))?/

Instance Method Summary collapse

Instance Method Details

#parse(page) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/holiday_scraper/parser.rb', line 8

def parse(page)
  events = []
  current_year = nil
  each_table_header_on(page) do |table_header|
    if year_header?(table_header)
      current_year = table_header.text
    elsif event_header?(table_header)
      events << as_event(current_year, table_header)
    end
  end
  events
end