Class: IcalImporter::RemoteEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/ical_importer/remote_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ RemoteEvent

Returns a new instance of RemoteEvent.



7
8
9
10
11
12
13
14
# File 'lib/ical_importer/remote_event.rb', line 7

def initialize(event)
  @event = event
  begin
    @utc = @event.dtstart.tz_utc
  rescue
    @utc = true
  end
end

Instance Attribute Details

#eventObject

Returns the value of attribute event.



3
4
5
# File 'lib/ical_importer/remote_event.rb', line 3

def event
  @event
end

#utcObject Also known as: utc?

Returns the value of attribute utc.



3
4
5
# File 'lib/ical_importer/remote_event.rb', line 3

def utc
  @utc
end

Instance Method Details

#all_day_event?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
# File 'lib/ical_importer/remote_event.rb', line 28

def all_day_event?
  begin
    (Time.parse(end_date_time.to_s) - Time.parse(start_date_time.to_s)) >= 1.day
  rescue ArgumentError => e # no time info in '', Defaulting to false
    false
  end
end

#end_date_timeObject



20
21
22
# File 'lib/ical_importer/remote_event.rb', line 20

def end_date_time
  get_date_time_for :dtend
end

#event_attributesObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ical_importer/remote_event.rb', line 36

def event_attributes
  {
    :uid => uid.to_s,
    :title => summary.to_s,
    :utc => utc?,
    :description => description.to_s,
    :location => location.to_s,
    :start_date_time => start_date_time,
    :end_date_time => end_date_time,
    :all_day_event => all_day_event?
  }
end

#recurrence_idObject



24
25
26
# File 'lib/ical_importer/remote_event.rb', line 24

def recurrence_id
  event.recurrence_id ? event.recurrence_id.to_datetime : nil
end

#start_date_timeObject



16
17
18
# File 'lib/ical_importer/remote_event.rb', line 16

def start_date_time
  get_date_time_for :dtstart
end