class URI::RFC2396_Parser
Class that parses String’s into URI’s.
It contains a Hash set of patterns and Regexp’s that match and validate.
Attributes
The Hash of patterns.
See also #initialize_pattern.
Public Class Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 65
def initialize: (?Hash[Symbol, String] opts) -> void
Synopsis
URI::RFC2396_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 generates set of regexps for parsing URIs.
You can use the following keys:
* :ESCAPED (URI::PATTERN::ESCAPED in default) * :UNRESERVED (URI::PATTERN::UNRESERVED in default) * :DOMLABEL (URI::PATTERN::DOMLABEL in default) * :TOPLABEL (URI::PATTERN::TOPLABEL in default) * :HOSTNAME (URI::PATTERN::HOSTNAME in default)
Examples
p = URI::RFC2396_Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD> URI.parse(u.to_s) #=> raises URI::InvalidURIError s = "http://example.com/ABCD" u1 = p.parse(s) #=> #<URI::HTTP http://example.com/ABCD> u2 = URI.parse(s) #=> #<URI::HTTP http://example.com/ABCD> u1 == u2 #=> true u1.eql?(u2) #=> false
Public Instance Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 86
def escape: (String str, ?Regexp unsafe) -> String
Args
Description
Constructs a safe String from str, removing unsafe characters, replacing them with codes.
(String str, ?Array[String] schemes) → Array[String]
(String str, ?Array[String] schemes) { (String) → untyped } → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 110
def extract: (String str, ?Array[String] schemes) -> Array[String]
| (String str, ?Array[String] schemes) { (String) -> untyped } -> nil
Args
str-
Stringto search schemes-
Patterns to apply to
str
Description
Attempts to parse and merge a set of URIs. If no block given, then returns the result, else it calls block for each element in result.
See also make_regexp.
(*String uris) → URI::Generic
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 127
def join: (*String uris) -> URI::Generic
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 137
def make_regexp: (?Array[String] schemes) -> Regexp
Returns Regexp that is default self.regexp[:ABS_URI_REF], unless schemes is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI].
(String uri) → URI::Generic
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 159
def parse: (String uri) -> URI::Generic
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 167
def split: (String uri) -> [ String?, String?, String?, String?, String?, String?, String?, String?, String? ]
Returns a split URI against regexp[:ABS_URI].
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/uri/0/rfc2396_parser.rbs, line 187
def unescape: (String str, ?Regexp escaped) -> String