Class: IcalImporter::LocalEvent
- Inherits:
-
Object
- Object
- IcalImporter::LocalEvent
- Defined in:
- lib/ical_importer/local_event.rb
Constant Summary collapse
- DAYS =
%w[sunday monday tuesday wednesday thursday friday saturday]
Class Attribute Summary collapse
-
.class_attributes ⇒ Object
Returns the value of attribute class_attributes.
Instance Method Summary collapse
- #attributes=(attributes) ⇒ Object
- #get_attributes(list) ⇒ Object
-
#initialize(attributes) ⇒ LocalEvent
constructor
A new instance of LocalEvent.
- #to_hash ⇒ Object (also: #attributes)
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_attributes ⇒ Object
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
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_hash ⇒ Object 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 |