Class: Calagator::Source::Parser::Plancast

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

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



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/calagator/source/parser/plancast.rb', line 7

def to_events
  return unless data = get_data
  event = Event.new({
    source:      source,
    title:       data['what'],
    description: data['description'],

    # Plancast is sending floating times as Unix timestamps, which is hard to parse
    start_time:  ActiveSupport::TimeWithZone.new(nil, Time.zone, Time.at(data['start'].to_i).utc),
    end_time:    ActiveSupport::TimeWithZone.new(nil, Time.zone, Time.at(data['stop'].to_i).utc),

    url:         (data['external_url'] || data['plan_url']),
    tag_list:    "plancast:plan=#{data['event_id']}",

    venue:       to_venue(data['place'], data['where']),
  })

  [event_or_duplicate(event)]
end