class Vpim::Rrule::Maker

Help encode an RRULE value.

TODO - the Maker is both incomplete, and its a bit cheesy, I'd like to do something that is a kind of programmatic version of the UI that iCal has.

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/vpim/rrule.rb, line 529
def initialize(&block) #:yield: self
  @freq = nil
  @until = nil
  @count = nil
  @interval = nil
  @wkst = nil
  @by = {}

  if block
    yield self
  end
end

Public Instance Methods

count=(rcount) click to toggle source

count is integral

# File lib/vpim/rrule.rb, line 561
def count=(rcount)
  if @until
    raise ArgumentError, "Cannot specify COUNT if UNTIL was specified"
  end
  @count = rcount.to_int
end
encode() click to toggle source

TODO - BY.…

# File lib/vpim/rrule.rb, line 570
def encode
  unless @freq
    raise ArgumentError, "Must specify FREQUENCY"
  end

  rrule = "FREQ=#{@freq}"

  [
    ["COUNT", @count],
    ["UNTIL", @until],
    # TODO...
  ].each do |k,v|
    if v
      rrule += ";#{k}=#{v}"
    end
  end
  rrule
end
frequency=(freq) click to toggle source
# File lib/vpim/rrule.rb, line 544
def frequency=(freq)
  freq = freq.to_str.upcase
  unless FREQ.include? freq
    raise ArgumentError, "Frequency #{freq} is not valid"
  end
  @freq = freq
end
until(=(runtil)) click to toggle source

runtil is Time, Date, or DateTime

# File lib/vpim/rrule.rb, line 553
def until=(runtil)
  if @count
    raise ArgumentError, "Cannot specify UNTIL if COUNT was specified"
  end
  @until = runtil
end