Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
URI.parser=
parser=(parser = RFC3986_PARSER)
lib/uri/common.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/uri/common.rb, line 29
def self.parser=(parser = RFC3986_PARSER)
remove_const(:Parser) if defined?(::URI::Parser)
const_set("Parser", parser.class)
remove_const(:PARSER) if defined?(::URI::PARSER)
const_set("PARSER", parser)
remove_const(:REGEXP) if defined?(::URI::REGEXP)
remove_const(:PATTERN) if defined?(::URI::PATTERN)
if Parser == RFC2396_Parser
const_set("REGEXP", URI::RFC2396_REGEXP)
const_set("PATTERN", URI::RFC2396_REGEXP::PATTERN)
end
Parser.new.regexp.each_pair do |sym, str|
remove_const(sym) if const_defined?(sym, false)
const_set(sym, str)
end
end
Set the default parser instance.