Class: Vpim::Agent::Calendars::Calendar

Inherits:
Object
  • Object
show all
Defined in:
lib/vpim/agent/calendars.rb

Instance Method Summary collapse

Constructor Details

#initialize(cal) ⇒ Calendar

Returns a new instance of Calendar.



126
127
128
129
130
131
132
133
134
135
136
# File 'lib/vpim/agent/calendars.rb', line 126

def initialize(cal)
  @cal = cal
  @list = ResourceList.new(
      "Calendar #{@cal.name.inspect}:",
      [
        ["calendar", "download"],
        ["calendar", "subscription", "webcal"],
        ["atom",     "syndication"],
      ]
    )
end

Instance Method Details

#get(path) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/vpim/agent/calendars.rb', line 138

def get(path)
  form = path.shift

  # TODO should redirect to an object, so that extra paths can be
  # handled more gracefully.
  case form
  when nil
    return @list.get(path)
  when "calendar"
    return @cal.encode, Form::ICS
  when "atom"
    return Atomize.calendar(@cal, path.uri, nil, @cal.name).to_xml, Form::ATOM
  else
    raise NotFound.new(form, path)
  end
end