Class: CalInvite::Providers::Yahoo

Inherits:
BaseProvider show all
Defined in:
lib/cal_invite/providers/yahoo.rb

Overview

Yahoo Calendar provider for generating calendar event URLs. This provider generates URLs that open the Yahoo Calendar with a pre-filled event creation form. Supports all-day events, regular events, and multi-day sessions with proper timezone handling.

Note: Yahoo Calendar handles multi-day sessions differently from other providers, generating separate event URLs for each session.

Examples:

Creating a regular event URL

event = CalInvite::Event.new(
  title: "Team Meeting",
  start_time: Time.now,
  end_time: Time.now + 3600,
  description: "Weekly team sync",
  timezone: "America/New_York"
)
yahoo = CalInvite::Providers::Yahoo.new(event)
url = yahoo.generate

Creating a multi-day event URL

event = CalInvite::Event.new(
  title: "Conference",
  multi_day_sessions: [
    { start_time: Time.parse("2024-04-01 09:00"), end_time: Time.parse("2024-04-01 17:00") },
    { start_time: Time.parse("2024-04-02 09:00"), end_time: Time.parse("2024-04-02 17:00") }
  ]
)
urls = CalInvite::Providers::Yahoo.new(event).generate # Returns multiple URLs

Constant Summary collapse

BASE_URL =

Base URL for Yahoo Calendar

"https://calendar.yahoo.com"

Instance Attribute Summary

Attributes inherited from BaseProvider

#event

Instance Method Summary collapse

Methods inherited from BaseProvider

#initialize

Constructor Details

This class inherits a constructor from BaseProvider

Instance Method Details

#generateString

Generates Yahoo Calendar URL(s) for the event. Handles all event types: all-day, regular, and multi-day sessions.

Returns:

  • (String)

    A single URL for regular or all-day events, or multiple URLs (separated by newlines) for multi-day sessions

Raises:

  • (ArgumentError)

    If required time fields are missing for non-all-day events



44
45
46
47
48
49
50
51
52
# File 'lib/cal_invite/providers/yahoo.rb', line 44

def generate
  if event.all_day
    generate_all_day_event
  elsif event.multi_day_sessions.any?
    generate_multi_day_event
  else
    generate_single_event
  end
end