Class: IcalImporter::LocalEvent

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

Constant Summary collapse

DAYS =
%w[sunday monday tuesday wednesday thursday friday saturday]

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ LocalEvent

Returns a new instance of LocalEvent.



37
38
39
40
# File 'lib/ical_importer/local_event.rb', line 37

def initialize(attributes)
  self.attributes = attributes
  @date_exclusions ||= []
end

Class Attribute Details

.class_attributesObject

Returns the value of attribute class_attributes.



4
5
6
# File 'lib/ical_importer/local_event.rb', line 4

def class_attributes
  @class_attributes
end

Instance Method Details

#attributes=(attributes) ⇒ Object



53
54
55
56
57
# File 'lib/ical_importer/local_event.rb', line 53

def attributes=(attributes)
  attributes.each do |name, value|
    instance_variable_set "@#{name}", value if self.class.class_attributes.include? name.to_sym
  end
end

#get_attributes(list) ⇒ Object

Raises:

  • (ArgumentError)


42
43
44
45
46
# File 'lib/ical_importer/local_event.rb', line 42

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

#to_hashObject Also known as: attributes



48
49
50
# File 'lib/ical_importer/local_event.rb', line 48

def to_hash
  Hash[*self.class.class_attributes.collect { |attribute| [attribute.to_sym, send(attribute)] }.flatten(1)]
end