Class: Vpim::Repo::Uri

Inherits:
Vpim::Repo show all
Defined in:
lib/vpim/repo.rb

Defined Under Namespace

Classes: Calendar

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(where) ⇒ Uri

Returns a new instance of Uri.



250
251
252
# File 'lib/vpim/repo.rb', line 250

def initialize(where)
  @where = Uri.uri_check(where)
end

Class Method Details

.uri_check(uri) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/vpim/repo.rb', line 185

def self.uri_check(uri)
  uri = case uri
         when URI
           uri
         else
           begin
             URI.parse(uri.sub(/^webcal:/, "http:"))
           rescue URI::InvalidURIError => e
             raise ArgumentError, "Invalid URI for #{uri.inspect} - #{e.to_s}"
           end
         end
  unless uri.scheme == "http"
    raise ArgumentError, "Unsupported URI scheme for #{uri.inspect}"
  end
  uri
end

Instance Method Details

#each {|Calendar.new(@where)| ... } ⇒ Object

:nodoc:

Yields:



254
255
256
257
# File 'lib/vpim/repo.rb', line 254

def each #:nodoc:
  yield Calendar.new(@where)
  self
end