method
new
v1_9_2_180 -
Show latest stable
-
0 notes -
Class: Parser
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (-2)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
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