Class: IOStreams::Utils::URI
- Inherits:
-
Object
- Object
- IOStreams::Utils::URI
- Defined in:
- lib/io_streams/utils.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(url) ⇒ URI
constructor
A new instance of URI.
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
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
39 40 41 |
# File 'lib/io_streams/utils.rb', line 39 def hostname @hostname end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
39 40 41 |
# File 'lib/io_streams/utils.rb', line 39 def password @password end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
39 40 41 |
# File 'lib/io_streams/utils.rb', line 39 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
39 40 41 |
# File 'lib/io_streams/utils.rb', line 39 def port @port end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
39 40 41 |
# File 'lib/io_streams/utils.rb', line 39 def query @query end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
39 40 41 |
# File 'lib/io_streams/utils.rb', line 39 def scheme @scheme end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
39 40 41 |
# File 'lib/io_streams/utils.rb', line 39 def user @user end |