module ICalPal

def self.call(klass)

Returns:
  • (Class) - The subclass of ICalPal

Parameters:
  • klass (String) -- One of +accounts+, +stores+, +calendars+, or +events+
def self.call(klass)
  case klass
  when 'accounts' then Store
  when 'stores' then Store
  when 'calendars' then Calendar
  when 'events' then Event
  when 'tasks' then Task
  else
    $log.fatal("Unknown class: #{klass}")
    exit
  end
end

def self.nth(n, dow, m)

Returns:
  • (RDT) - The resulting day

Parameters:
  • m (RDT) -- The RDT with the year and month we're searching
  • dow (String) -- Day of the week abbreviation from ICalPal::DOW
  • n (Integer) -- Integer between -4 and +4
def self.nth(n, dow, m)
  # Get the number of days in the month
  a = [ ICalPal::RDT.new(m.year, m.month, 1) ] # First of this month
  a[1] = (a[0] >> 1) - 1      # First of next month, minus 1 day
  # Reverse it if going backwards
  a.reverse! if n.negative?
  step = a[1] <=> a[0]
  j = 0
  a[0].step(a[1], step) do |i|
    j += step if i.wday == DOW[dow.to_sym]
    return i if j == n
  end
end

def [](k) @self[k] end

@!group Accessors
def [](k) @self[k] end

def []=(k, v) @self[k] = v end

def []=(k, v) @self[k] = v end

def initialize(obj)

Parameters:
  • obj (ICalPal) -- A +Store+ or +Calendar+
def initialize(obj)
  obj['type'] = EventKit::EKSourceType.find_index { |i| i[:name] == 'Subscribed' } if obj['subcal_url']
  type = EventKit::EKSourceType[obj['type']]
  obj['store'] = obj['account']
  obj['type'] = type[:name]
  obj['color'] ||= type[:color]
  obj['symbolic_color_name'] ||= type[:color]
  @self = obj
end

def keys() @self.keys end

def keys() @self.keys end

def values() @self.values end

def values() @self.values end