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.
-
#allow_counter ⇒ Object
Returns the value of attribute allow_counter.
-
#attendees ⇒ Object
Returns the value of attribute attendees.
-
#busy ⇒ Object
Returns the value of attribute busy.
-
#calendar_name ⇒ Object
Returns the value of attribute calendar_name.
-
#description ⇒ Object
Returns the value of attribute description.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#geo ⇒ Object
Returns the value of attribute geo.
-
#importance ⇒ Object
Returns the value of attribute importance.
-
#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.
-
#organizer ⇒ Object
Returns the value of attribute organizer.
-
#reminders ⇒ Object
Returns the value of attribute reminders.
-
#rrule ⇒ Object
Returns the value of attribute rrule.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#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.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#url ⇒ Object
Returns the value of attribute url.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Instance Method Summary collapse
-
#generate_calendar_url(provider, method: :publish) ⇒ String
Generates a calendar URL (or, for the ics/ical/ics_content providers, raw iCalendar content) 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.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/cal_invite/event.rb', line 95 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 @uid = attributes.delete(:uid) || generate_uid @sequence = attributes.delete(:sequence) || 0 @busy = attributes.key?(:busy) ? attributes.delete(:busy) : true @visibility = attributes.delete(:visibility) || :public @allow_counter = attributes.key?(:allow_counter) ? attributes.delete(:allow_counter) : true 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.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def all_day @all_day end |
#allow_counter ⇒ Object
Returns the value of attribute allow_counter.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def allow_counter @allow_counter end |
#attendees ⇒ Object
Returns the value of attribute attendees.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def attendees @attendees end |
#busy ⇒ Object
Returns the value of attribute busy.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def busy @busy end |
#calendar_name ⇒ Object
Returns the value of attribute calendar_name.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def calendar_name @calendar_name end |
#description ⇒ Object
Returns the value of attribute description.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def description @description end |
#end_time ⇒ Object
Returns the value of attribute end_time.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def end_time @end_time end |
#geo ⇒ Object
Returns the value of attribute geo.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def geo @geo end |
#importance ⇒ Object
Returns the value of attribute importance.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def importance @importance end |
#location ⇒ Object
Returns the value of attribute location.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def location @location end |
#multi_day_sessions ⇒ Object
Returns the value of attribute multi_day_sessions.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def multi_day_sessions @multi_day_sessions end |
#notes ⇒ Object
Returns the value of attribute notes.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def notes @notes end |
#organizer ⇒ Object
Returns the value of attribute organizer.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def organizer @organizer end |
#reminders ⇒ Object
Returns the value of attribute reminders.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def reminders @reminders end |
#rrule ⇒ Object
Returns the value of attribute rrule.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def rrule @rrule end |
#sequence ⇒ Object
Returns the value of attribute sequence.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def sequence @sequence end |
#show_attendees ⇒ Object
Returns the value of attribute show_attendees.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def show_attendees @show_attendees end |
#start_time ⇒ Object
Returns the value of attribute start_time.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def start_time @start_time end |
#timezone ⇒ Object
Returns the value of attribute timezone.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def timezone @timezone end |
#title ⇒ Object
Returns the value of attribute title.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def title @title end |
#uid ⇒ Object
Returns the value of attribute uid.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def uid @uid end |
#url ⇒ Object
Returns the value of attribute url.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def url @url end |
#visibility ⇒ Object
Returns the value of attribute visibility.
38 39 40 |
# File 'lib/cal_invite/event.rb', line 38 def visibility @visibility end |
Instance Method Details
#generate_calendar_url(provider, method: :publish) ⇒ String
Generates a calendar URL (or, for the ics/ical/ics_content providers, raw iCalendar content) for the specified provider.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/cal_invite/event.rb', line 149 def generate_calendar_url(provider, method: :publish) validate! if caching_enabled? cache_key = cache_key_for(provider, method) 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, method: method) 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.
180 181 182 183 184 185 186 187 |
# File 'lib/cal_invite/event.rb', line 180 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 |