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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/io_streams/utils.rb', line 39 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.
37 38 39 |
# File 'lib/io_streams/utils.rb', line 37 def hostname @hostname end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
37 38 39 |
# File 'lib/io_streams/utils.rb', line 37 def password @password end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
37 38 39 |
# File 'lib/io_streams/utils.rb', line 37 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
37 38 39 |
# File 'lib/io_streams/utils.rb', line 37 def port @port end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
37 38 39 |
# File 'lib/io_streams/utils.rb', line 37 def query @query end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
37 38 39 |
# File 'lib/io_streams/utils.rb', line 37 def scheme @scheme end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
37 38 39 |
# File 'lib/io_streams/utils.rb', line 37 def user @user end |