Sha256: a168fcee83d115b599659536d6f87af2deba81aca5c8671030d1d063f327d2f5
Contents?: true
Size: 1.56 KB
Versions: 4
Compression:
Stored size: 1.56 KB
Contents
module IcalImporter class RemoteEvent attr_accessor :event, :utc alias :utc? :utc delegate :uid, :summary, :location, :description, :rrule, :exdate, :to => :event def initialize(event) @event = event begin @utc = @event.dtstart.tz_utc rescue @utc = true end end def start_date_time get_date_time_for :dtstart end def end_date_time get_date_time_for :dtend end def recurrence_id event.recurrence_id ? event.recurrence_id.to_datetime : nil end 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 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 private def get_date_time_for(event_method) event_method = event_method.to_sym raise ArgumentError, "Should be dtend or dtstart" unless [:dtstart, :dtend].include? event_method event_time = event.send event_method if event_time.respond_to?(:tz_utc) (event_time.tz_utc) ? event_time.utc : event_time.to_datetime else begin event_time.to_datetime rescue event_time end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems