Class: CalInvite::Event
- Inherits:
-
Object
- Object
- CalInvite::Event
- Defined in:
- lib/cal_invite/event.rb
Instance Attribute Summary collapse
-
#all_day ⇒ Object
Returns the value of attribute all_day.
-
#attendees ⇒ Object
Returns the value of attribute attendees.
-
#description ⇒ Object
Returns the value of attribute description.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#location ⇒ Object
Returns the value of attribute location.
-
#multi_day_sessions ⇒ Object
Returns the value of attribute multi_day_sessions.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#show_attendees ⇒ Object
Returns the value of attribute show_attendees.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#generate_calendar_url(provider) ⇒ String
Generates a calendar URL for the specified provider.
-
#initialize(attributes = {}) ⇒ Event
constructor
Initializes a new Event instance with the given attributes.
-
#update_attributes(new_attributes) ⇒ void
Updates the event attributes with new values.
Constructor Details
#initialize(attributes = {}) ⇒ Event
Initializes a new Event instance with the given attributes.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cal_invite/event.rb', line 52 def initialize(attributes = {}) @show_attendees = attributes.delete(:show_attendees) || false @timezone = attributes.delete(:timezone) || 'UTC' @multi_day_sessions = attributes.delete(:multi_day_sessions) || [] @all_day = attributes.delete(:all_day) || false attributes.each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end validate! end |
Instance Attribute Details
#all_day ⇒ Object
Returns the value of attribute all_day.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def all_day @all_day end |
#attendees ⇒ Object
Returns the value of attribute attendees.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def attendees @attendees end |
#description ⇒ Object
Returns the value of attribute description.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def description @description end |
#end_time ⇒ Object
Returns the value of attribute end_time.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def end_time @end_time end |
#location ⇒ Object
Returns the value of attribute location.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def location @location end |
#multi_day_sessions ⇒ Object
Returns the value of attribute multi_day_sessions.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def multi_day_sessions @multi_day_sessions end |
#notes ⇒ Object
Returns the value of attribute notes.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def notes @notes end |
#show_attendees ⇒ Object
Returns the value of attribute show_attendees.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def show_attendees @show_attendees end |
#start_time ⇒ Object
Returns the value of attribute start_time.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def start_time @start_time end |
#timezone ⇒ Object
Returns the value of attribute timezone.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def timezone @timezone end |
#title ⇒ Object
Returns the value of attribute title.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
22 23 24 |
# File 'lib/cal_invite/event.rb', line 22 def url @url end |
Instance Method Details
#generate_calendar_url(provider) ⇒ String
Generates a calendar URL for the specified provider.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/cal_invite/event.rb', line 76 def generate_calendar_url(provider) validate! if caching_enabled? cache_key = cache_key_for(provider) cached_url = fetch_from_cache(cache_key) return cached_url if cached_url end # Generate the URL provider_class = CalInvite::Providers.const_get(capitalize_provider(provider.to_s)) generator = provider_class.new(self) url = generator.generate # Cache the result if caching is enabled write_to_cache(cache_key, url) if caching_enabled? url end |
#update_attributes(new_attributes) ⇒ void
This method returns an undefined value.
Updates the event attributes with new values.
107 108 109 110 111 112 113 114 |
# File 'lib/cal_invite/event.rb', line 107 def update_attributes(new_attributes) new_attributes.each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end invalidate_cache if caching_enabled? validate! end |