Method: HTTP::URI#initialize

Defined in:
lib/http/uri.rb

#initialize(options_or_uri = {}) ⇒ HTTP::URI

Creates an HTTP::URI instance from the given options

Parameters:

  • options_or_uri (Hash, Addressable::URI) (defaults to: {})

Options Hash (options_or_uri):

  • :scheme (String, #to_str)

    URI scheme

  • :user (String, #to_str)

    for basic authentication

  • :password (String, #to_str)

    for basic authentication

  • :host (String, #to_str)

    name component

  • :port (String, #to_str)

    network port to connect to

  • :path (String, #to_str)

    component to request

  • :query (String, #to_str)

    component distinct from path

  • :fragment (String, #to_str)

    component at the end of the URI



64
65
66
67
68
69
70
71
72
73
# File 'lib/http/uri.rb', line 64

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