Class: IOStreams::Utils::URI

Inherits:
Object
  • Object
show all
Defined in:
lib/io_streams/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ URI

Returns a new instance of URI.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/io_streams/utils.rb', line 41

def initialize(url)
  url       = url.gsub(" ", "%20")
  uri       = ::URI.parse(url)
  @scheme   = uri.scheme
  @hostname = uri.hostname
  @path     = CGI.unescape(uri.path)
  @user     = uri.user
  @password = uri.password
  @port     = uri.port
  return unless uri.query

  @query = {}
  ::URI.decode_www_form(uri.query).each { |key, value| @query[key] = value }
end

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



39
40
41
# File 'lib/io_streams/utils.rb', line 39

def hostname
  @hostname
end

#passwordObject (readonly)

Returns the value of attribute password.



39
40
41
# File 'lib/io_streams/utils.rb', line 39

def password
  @password
end

#pathObject (readonly)

Returns the value of attribute path.



39
40
41
# File 'lib/io_streams/utils.rb', line 39

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



39
40
41
# File 'lib/io_streams/utils.rb', line 39

def port
  @port
end

#queryObject (readonly)

Returns the value of attribute query.



39
40
41
# File 'lib/io_streams/utils.rb', line 39

def query
  @query
end

#schemeObject (readonly)

Returns the value of attribute scheme.



39
40
41
# File 'lib/io_streams/utils.rb', line 39

def scheme
  @scheme
end

#userObject (readonly)

Returns the value of attribute user.



39
40
41
# File 'lib/io_streams/utils.rb', line 39

def user
  @user
end