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:



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

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

Instance Method Details

#bodyObject



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

def body
end

#displayedObject

:nodoc:



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

def displayed #:nodoc:
  true
end

#each(klass, &block) ⇒ Object

:nodoc:



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

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:



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

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:



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

def name #:nodoc:
  @uri.to_s
end