Type:
Module
Constants:
DEFAULT_PARSER : Parser.new

URI::Parser.new

TBLENCWWWCOMP_ : {}
TBLDECWWWCOMP_ : {}
HTML5ASCIIINCOMPAT : [Encoding::UTF_7, Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE]
WFKV_ : '(?:[^%#=;&]*(?:%\h\h[^%#=;&]*)*)'

URI is a module providing classes to handle Uniform Resource Identifiers (RFC2396)

Features

  • Uniform handling of handling URIs

  • Flexibility to introduce custom URI schemes

  • Flexibility to have an alternate URI::Parser (or just different patterns and regexp's)

Basic example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'uri'
 
uri = URI("http://foo.com/posts?id=30&limit=5#time=1305298413")
#=> #<URI::HTTP:0x00000000b14880
      URL:http://foo.com/posts?id=30&limit=5#time=1305298413>
uri.scheme
#=> "http"
uri.host
#=> "foo.com"
uri.path
#=> "/posts"
uri.query
#=> "id=30&limit=5"
uri.fragment
#=> "time=1305298413"
 
uri.to_s

Adding custom URIs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module URI
  class RSYNC < Generic
    DEFAULT_PORT = 873
  end
  @@schemes['RSYNC'] = RSYNC
end
#=> URI::RSYNC
 
URI.scheme_list
#=> {"FTP"=>URI::FTP, "HTTP"=>URI::HTTP, "HTTPS"=>URI::HTTPS,
     "LDAP"=>URI::LDAP, "LDAPS"=>URI::LDAPS, "MAILTO"=>URI::MailTo,
     "RSYNC"=>URI::RSYNC}
 
#=> #<URI::RSYNC:0x00000000f648c8 URL:rsync://rsync.foo.com>

RFC References

A good place to view an RFC spec is www.ietf.org/rfc.html

Here is a list of all related RFC's.

Class tree

Copyright Info

Author

Akira Yamada <akira@ruby-lang.org>

Documentation

Akira Yamada <akira@ruby-lang.org> Dmitry V. Sabanin <sdmitry@lrn.ru> Vincent Batts <vbatts@hashbangbash.com>

License

Copyright © 2001 akira yamada <akira@ruby-lang.org> You can redistribute it and/or modify it under the same term as Ruby.

Revision

$Id$

filter
  • References/Ruby on Rails/Ruby/Classes/URI/URI::LDAP

filter() Instance Public methods returns filter.

2025-01-10 15:47:30
to=
  • References/Ruby on Rails/Ruby/Classes/URI/URI::MailTo

to=(v) Instance Public methods setter for to v

2025-01-10 15:47:30
path
  • References/Ruby on Rails/Ruby/Classes/URI/URI::FTP

path() Instance Public methods Returns the path from an

2025-01-10 15:47:30
registry=
  • References/Ruby on Rails/Ruby/Classes/URI/URI::Generic

registry=(v) Instance Public methods Args v

2025-01-10 15:47:30
escape
  • References/Ruby on Rails/Ruby/Classes/URI/URI::Parser

escape( str )escape( str, unsafe ) Instance Public methods Args

2025-01-10 15:47:30
fragment=
  • References/Ruby on Rails/Ruby/Classes/URI/URI::Generic

fragment=(v) Instance Public methods Args v

2025-01-10 15:47:30
route_from
  • References/Ruby on Rails/Ruby/Classes/URI/URI::Generic

route_from(oth) Instance Public methods Args oth

2025-01-10 15:47:30
parse
  • References/Ruby on Rails/Ruby/Classes/URI/URI::Parser

parse(uri) Instance Public methods Args uri

2025-01-10 15:47:30
to_s
  • References/Ruby on Rails/Ruby/Classes/URI/URI::MailTo

to_s() Instance Public methods Constructs String from

2025-01-10 15:47:30
set_userinfo
  • References/Ruby on Rails/Ruby/Classes/URI/URI::Generic

set_userinfo(user, password = nil) Instance Protected methods protect setter

2025-01-10 15:47:30