class HTTP::URI
Constants
- HTTPS_SCHEME
@private
- HTTP_SCHEME
@private
Public Class Methods
Encodes key/value pairs as application/x-www-form-urlencoded
@param [#to_hash, to_ary] :form_values to encode @param [TrueClass, FalseClass] :sort should key/value pairs be sorted first?
@return [String] encoded value
# File lib/http/uri.rb, line 44 def self.form_encode(form_values, sort = false) Addressable::URI.form_encode(form_values, sort) end
Creates an HTTP::URI instance from the given options
@option [String, to_str] :scheme URI scheme @option [String, to_str] :user for basic authentication @option [String, to_str] :password for basic authentication @option [String, to_str] :host name component @option [String, to_str] :port network port to connect to @option [String, to_str] :path component to request @option [String, to_str] :query component distinct from path @option [String, to_str] :fragment component at the end of the URI
@return [HTTP::URI] new URI instance
# File lib/http/uri.rb, line 60 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
Public Instance Methods
Are these URI objects equal? Normalizes both URIs prior to comparison
@param [Object] :other URI to compare this one with
@return [TrueClass, FalseClass] are the URIs equivalent (after normalization)?
# File lib/http/uri.rb, line 75 def ==(other) other.is_a?(URI) && normalize.to_s == other.normalize.to_s end
@return [True] if URI is HTTPS @return [False] otherwise
# File lib/http/uri.rb, line 110 def https? HTTPS_SCHEME == scheme end
@return [String] human-readable representation of URI
# File lib/http/uri.rb, line 123 def inspect format("#<%s:0x%014x URI:%s>", self.class.name, object_id << 1, to_s) end
Port number, either as specified or the default if unspecified
@return [Integer] port number
# File lib/http/uri.rb, line 98 def port @uri.port || @uri.default_port end