method

new

Importance_2
v1_9_2_180 - Show latest stable - 0 notes - Class: Parser
new(opts = {}) public

Synopsis

URI::Parser.new([opts])

Args

The constructor accepts a hash as options for parser. Keys of options are pattern names of URI components and values of options are pattern strings. The constructor generetes set of regexps for parsing URIs.

You can use the following keys:

* <tt>:ESCAPED</tt> (URI::PATTERN::ESCAPED in default)
* <tt>:UNRESERVED</tt> (URI::PATTERN::UNRESERVED in default)
* <tt>:DOMLABEL</tt> (URI::PATTERN::DOMLABEL in default)
* <tt>:TOPLABEL</tt> (URI::PATTERN::TOPLABEL in default)
* <tt>:HOSTNAME</tt> (URI::PATTERN::HOSTNAME in default)

Examples

p = URI::Parser.new(:ESCPAED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})"
u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP:0xb78cf4f8 URL:http://example.jp/%uABCD>
URI.parse(u.to_s) #=> raises URI::InvalidURIError

s = "http://examle.com/ABCD"
u1 = p.parse(s) #=> #<URI::HTTP:0xb78c3220 URL:http://example.com/ABCD>
u2 = URI.parse(s) #=> #<URI::HTTP:0xb78b6d54 URL:http://example.com/ABCD>
u1 == u2 #=> true
u1.eql?(u2) #=> false
Show source
Register or log in to add new notes.