Class: BaseProvider Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/cal_invite/providers/base_provider.rb

Overview

This class is abstract.

Subclass and override #generate to implement a calendar provider

app/lib/base_provider.rb Base class for calendar providers that implements common functionality and defines the interface that all providers must implement.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event, method: :publish) ⇒ BaseProvider

Initialize a new calendar provider

Parameters:

  • event (CalInvite::Event)

    The event to generate a calendar URL for

  • method (Symbol) (defaults to: :publish)

    The iCalendar METHOD (:publish or :request). Only meaningful to the ics-family providers; URL-based providers ignore it.



16
17
18
19
# File 'lib/cal_invite/providers/base_provider.rb', line 16

def initialize(event, method: :publish)
  @event = event
  @method = method
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



9
10
11
# File 'lib/cal_invite/providers/base_provider.rb', line 9

def event
  @event
end

#methodObject (readonly)

Returns the value of attribute method.



9
10
11
# File 'lib/cal_invite/providers/base_provider.rb', line 9

def method
  @method
end

Instance Method Details

#generateString

This method is abstract.

Generate a calendar URL or content for the event. This method must be implemented by all provider subclasses.

Returns:

  • (String)

    The generated calendar URL or content

Raises:

  • (NotImplementedError)

    if the provider class doesn't implement this method



27
28
29
# File 'lib/cal_invite/providers/base_provider.rb', line 27

def generate
  raise NotImplementedError, "#{self.class} must implement #generate"
end