Class: Calagator::Source::Parser::Hcal

Inherits:
Calagator::Source::Parser show all
Defined in:
app/models/calagator/source/parser/hcal.rb

Constant Summary collapse

EVENT_TO_HCALENDAR_FIELD_MAP =
{
  :title => :summary,
  :description => :description,
  :start_time => :dtstart,
  :end_time => :dtend,
  :url => :url,
  :venue => :location,
}

Instance Attribute Summary

Attributes inherited from Calagator::Source::Parser

#source, #url

Instance Method Summary collapse

Methods inherited from Calagator::Source::Parser

<=>, inherited, labels, read_url, to_events

Instance Method Details

#to_eventsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/calagator/source/parser/hcal.rb', line 23

def to_events
  hcals.map do |hcal|
    event = Event.new
    event.source = source
    EVENT_TO_HCALENDAR_FIELD_MAP.each do |field, mofo_field|
      next unless hcal.respond_to?(mofo_field)
      next unless value = decoded_field(hcal, mofo_field)
      event.send "#{field}=", value
    end
    event_or_duplicate(event)
  end.uniq do |event|
    [event.attributes, event.venue.try(:attributes)]
  end
end