Sha256: 499fa790d2ec28d9d98f99e8e3f16a32579f3b18622fc5a491d5605c6777121e
Contents?: true
Size: 1.43 KB
Versions: 28
Compression:
Stored size: 1.43 KB
Contents
module IcalImporter class LocalEvent class << self attr_accessor :class_attributes end @class_attributes = [ :uid, :title, :description, :location, :start_date_time, :end_date_time, :utc, :date_exclusions, :recur_end_date, :recur_month_repeat_by, :recur_interval, :recur_interval_value, :recur_end_date, :recurrence_id, :all_day_event, :recurrence ] attr_accessor *class_attributes alias utc? utc alias all_day_event? all_day_event alias recurrence? recurrence DAYS = %w[sunday monday tuesday wednesday thursday friday saturday] DAYS.each do |day| class_attributes << "recur_week_#{day}".to_sym attr_accessor "recur_week_#{day}" end def initialize(attributes) self.attributes = attributes @date_exclusions ||= [] end def get_attributes(list) raise ArgumentError, "Must be an Array" unless list.is_a? Array list.collect! { |e| e.to_s } attributes.select { |k,_| list.include? k.to_s } end def to_hash Hash[*self.class.class_attributes.collect { |attribute| [attribute.to_sym, send(attribute)] }.flatten(1)] end alias :attributes :to_hash def attributes=(attributes) attributes.each do |name, value| instance_variable_set "@#{name}", value if self.class.class_attributes.include? name.to_sym end end end end
Version data entries
28 entries across 28 versions & 1 rubygems