class HTTP::URI
def self.form_encode(form_values, sort = false)
-
(String)
- encoded value
Parameters:
-
:sort
(TrueClass, FalseClass
) -- should key/value pairs be sorted first? -
:form_values
(#to_hash, #to_ary
) -- to encode
def self.form_encode(form_values, sort = false) Addressable::URI.form_encode(form_values, sort) end
def self.parse(uri)
-
(HTTP::URI)
- new URI instance
Parameters:
-
:uri
(HTTP::URI, String, #to_str
) -- to parse
def self.parse(uri) return uri if uri.is_a?(self) new(Addressable::URI.parse(uri)) end
def ==(other)
-
(TrueClass, FalseClass)
- are the URIs equivalent (after normalization)?
Parameters:
-
:other
(Object
) -- URI to compare this one with
def ==(other) other.is_a?(URI) && normalize.to_s == other.normalize.to_s end
def eql?(other)
-
(TrueClass, FalseClass)
- are the URIs equivalent?
Parameters:
-
:other
(Object
) -- URI to compare this one with
def eql?(other) other.is_a?(URI) && to_s == other.to_s end
def hash
-
(Integer)
- A hash of the URI
def hash @hash ||= to_s.hash * -1 end
def http?
-
(False)
- otherwise -
(True)
- if URI is HTTP
def http? HTTP_SCHEME == scheme end
def https?
-
(False)
- otherwise -
(True)
- if URI is HTTPS
def https? HTTPS_SCHEME == scheme end
def initialize(options_or_uri = {})
-
(HTTP::URI)
- new URI instance
Options Hash:
(**[String,)
-
#to_str
(]
) -- to_str] :fragment component at the end of the URI -
#to_str
(]
) -- to_str] :query component distinct from path -
#to_str
(]
) -- to_str] :path component to request -
#to_str
(]
) -- to_str] :port network port to connect to -
#to_str
(]
) -- to_str] :host name component -
#to_str
(]
) -- to_str] :password for basic authentication -
#to_str
(]
) -- to_str] :user for basic authentication -
#to_str
(]
) -- to_str] :scheme URI scheme
def initialize(options_or_uri = {}) case options_or_uri when Hash @uri = Addressable::URI.new(options_or_uri) when Addressable::URI @uri = options_or_uri else raise TypeError, "expected Hash for options, got #{options_or_uri.class}" end end
def inspect
-
(String)
- human-readable representation of URI
def inspect format("#<%s:0x%014x URI:%s>", self.class.name, object_id << 1, to_s) end
def port
-
(Integer)
- port number
def port @uri.port || @uri.default_port end
def to_s
-
(String)
- URI serialized as a String
def to_s @uri.to_s end