Class: Vpim::Repo::Uri::Calendar

Inherits:
Calendar
  • Object
show all
Defined in:
lib/vpim/repo.rb

Instance Method Summary collapse

Methods inherited from Calendar

#events, #file_each, #todos

Constructor Details

#initialize(uri) ⇒ Calendar

:nodoc:



207
208
209
# File 'lib/vpim/repo.rb', line 207

def initialize(uri) #:nodoc:
  @uri = Uri.uri_check(uri)
end

Instance Method Details

#bodyObject



204
205
# File 'lib/vpim/repo.rb', line 204

def body
end

#displayedObject

:nodoc:



215
216
217
# File 'lib/vpim/repo.rb', line 215

def displayed #:nodoc:
  true
end

#each(klass, &block) ⇒ Object

:nodoc:



219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/vpim/repo.rb', line 219

def each(klass, &block) #:nodoc:
  unless iterator?
    return Enumerable::Enumerator.new(self, :each, klass)
  end

  cals = Vpim::Icalendar.decode(encode)

  cals.each do |cal|
    cal.each(klass, &block)
  end
  self
end

#encodeObject

:nodoc:



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/vpim/repo.rb', line 232

def encode #:nodoc:
  Net::HTTP.get_response(@uri) do |result|
    accum = ""
=begin
better to let this pass up as an invalid encoding error
    if result.code != "200"
      raise StandardError,
        "HTTP GET of #{@uri.to_s.inspect} failed with #{result.code} #{result.error_type}"
    end
=end
    result.read_body do |chunk|
      accum << chunk
    end
    return accum
  end
end

#nameObject

:nodoc:



211
212
213
# File 'lib/vpim/repo.rb', line 211

def name #:nodoc:
  @uri.to_s
end