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.



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

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

Class Method Details

.uri_check(uri) ⇒ Object



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

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:



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

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