class Retriever::URI

Public Class Methods

new(uri) click to toggle source
# File core/lib/retriever/uri.rb, line 33
def initialize(uri)
  case uri.freeze
  when URI, Addressable::URI
    @uri = uri
  when String
    @uri_string = uri
  when Hash
    @uri_hash = uri
  end
end

Public Instance Methods

==(other) click to toggle source
# File core/lib/retriever/uri.rb, line 44
def ==(other)
  case other
  when URI, Addressable::URI
    other == to_uri
  when Retriever::URI
    if has_string? or other.has_string?
      to_s == other.to_s
    else
      other.to_uri == to_uri
    end
  end
end
freeze() click to toggle source
Calls superclass method
# File core/lib/retriever/uri.rb, line 90
def freeze
  unless frozen?
    to_uri
    to_s
  end
  super
end
has_string?() click to toggle source
# File core/lib/retriever/uri.rb, line 61
def has_string?
  !!@uri_string
end
has_uri?() click to toggle source
# File core/lib/retriever/uri.rb, line 65
def has_uri?
  !!@uri
end
hash() click to toggle source
# File core/lib/retriever/uri.rb, line 57
def hash
  to_s.hash ^ self.class.hash
end
method_missing(method, *rest, &block) click to toggle source
# File core/lib/retriever/uri.rb, line 102
def method_missing(method, *rest, &block)
  to_uri.__send__(method, *rest, &block)
end
respond_to?(method) click to toggle source
Calls superclass method
# File core/lib/retriever/uri.rb, line 98
def respond_to?(method)
  super or to_uri.respond_to?(method)
end
scheme() click to toggle source
# File core/lib/retriever/uri.rb, line 77
def scheme
  if has_string? and !has_uri?
    match = @uri_string.match(%r<\A(\w+)://>)
    if match
      match[1]
    else
      to_uri.scheme
    end
  else
    to_uri.scheme
  end
end
to_s() click to toggle source
# File core/lib/retriever/uri.rb, line 69
def to_s
  @uri_string ||= to_uri.to_s.freeze
end
to_uri() click to toggle source
# File core/lib/retriever/uri.rb, line 73
def to_uri
  @uri ||= generate_uri.freeze
end