Module: ScheduleScraper::Schedule

Included in:
EZLeagues::Schedule, Pointstreak::Schedule
Defined in:
lib/schedule-scraper/schedule.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



12
13
14
15
# File 'lib/schedule-scraper/schedule.rb', line 12

def self.included(base)
  base.extend ClassMethods
  Config.register_type base
end

Instance Method Details

#to_csvObject



25
26
27
28
29
30
31
32
# File 'lib/schedule-scraper/schedule.rb', line 25

def to_csv
  CSV.generate do |csv|
    csv << event_class.export_fields
    events.each do |event|
      csv << event.to_csv
    end
  end
end

#to_gcalObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/schedule-scraper/schedule.rb', line 45

def to_gcal
  headers = [
    "Subject",
    "Start Date",
    "Start Time",
    "End Date",
    "End Time",
    "All Day Event",
    "Description",
    "Location",
    "Private"
  ]

  CSV.generate do |csv|
    csv << headers
    events.each do |event|
      csv << event.to_gcal
    end
  end
end

#to_hObject



17
18
19
20
21
22
23
# File 'lib/schedule-scraper/schedule.rb', line 17

def to_h
  [].tap do |list|
    events.each do |event|
      list << event.to_h
    end
  end
end

#to_icalObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/schedule-scraper/schedule.rb', line 34

def to_ical
  # inside RiCal block events are not available
  local_events = events

  RiCal.Calendar do |cal|
    local_events.each do |local_event|
      local_event.to_ical(cal)
    end
  end
end

#to_ycalObject



66
67
68
69
70
71
72
73
74
75
# File 'lib/schedule-scraper/schedule.rb', line 66

def to_ycal
  headers = %w(name start_date start_time end_date end_time venue_name venue_location category_id description ticket_price ticket_free ticket_url event_url personal)

  CSV.generate do |csv|
    csv << headers
    events.each do |event|
      csv << event.to_ycal
    end
  end
end