require 'regexpr.rb' class Uri class Flags< Array class < '( "http" | "ftp" ) "s" ? | "sftp" | "fish"', :username => '[^:@]*', :password => '[^@]*', :host => 'hostname | ipv4', :port => 'digit +', :path => '( "/" ? [^?#]* "/" ) ?', :file => '[^/?#] *', :flags => '[^#] *', :fragment => '. *', 'ipv4digits' => '0..255', 'ipv6digits' => '[0-9a-bA-B] {1,4}', 'userinfo' => 'username ( ":" password ) ?', 'domainlabel' => 'alphadigit ( ( alphadigit | "-" ) * alphadigit ) ?', 'hostname' => 'domainlabel ( "." | domainlabel ) *', 'ipv4' => 'ipv4digits ( "." ipv4digits ) {3,3}', 'request_uri' => '( path ? file ) ? ( "?" flags ) ?', 'serv' => 'host ( ":" port ? ) ?', 'pre' => '( ( scheme "://" ) ( auth "@" ) ? serv ) ?', 'uri' => 'pre request_uri ( "#" fragment ) ?', 'main' => 'uri' ] RegExpr. def self, :path, :uri, :pre, :serv, :request_uri end def Uri( uri) Uri.new uri end class String def to_uri() Uri. new self end end