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 dup
-
(Object)
- duplicated URI
def dup self.class.new @uri.dup 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:
(**options_or_uri)
-
:fragment
(String, #to_str
) -- component at the end of the URI -
:query
(String, #to_str
) -- component distinct from path -
:path
(String, #to_str
) -- component to request -
:port
(String, #to_str
) -- network port to connect to -
:host
(String, #to_str
) -- name component -
:password
(String, #to_str
) -- for basic authentication -
:user
(String, #to_str
) -- for basic authentication -
:scheme
(String, #to_str
) -- URI scheme
Parameters:
-
options_or_uri
(Hash, Addressable::URI
) --
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