| Class | URI::FTP |
| In: |
lib/open-uri.rb
lib/uri/ftp.rb |
| Parent: | Object |
| DEFAULT_PORT | = | 21 | ||
| COMPONENT | = | [ :scheme, :userinfo, :host, :port, :path, :typecode | ||
| TYPECODE | = | ['a', 'i', 'd'].freeze | Typecode is "a", "i" or "d". | |
| TYPECODE_PREFIX | = | ';type='.freeze |
| typecode | [R] |
Creates a new URI::FTP object from components, with syntax checking.
The components accepted are userinfo, host, port, path and typecode.
The components should be provided either as an Array, or as a Hash with keys formed by preceding the component names with a colon.
If an Array is used, the components must be passed in the order [userinfo, host, port, path, typecode]
If the path supplied is absolute, it will be escaped in order to make it absolute in the URI. Examples:
require 'uri'
uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
'/path/file.> zip', 'i'])
puts uri.to_s -> ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=a
uri2 = URI::FTP.build({:host => 'ftp.example.com',
:path => 'ruby/src'})
puts uri2.to_s -> ftp://ftp.example.com/ruby/src
Creates a new URI::FTP object from generic URL components with no syntax checking.
Unlike build(), this method does not escape the path component as required by RFC1738; instead it is treated as per RFC2396.
Arguments are scheme, userinfo, host, port, registry, path, opaque, query and fragment, in that order.
Returns the path from an FTP URI.
RFC 1738 specifically states that the path for an FTP URI does not include the / which separates the URI path from the URI host. Example:
ftp://ftp.example.com/pub/ruby
The above URI indicates that the client should connect to ftp.example.com then cd pub/ruby from the initial login directory.
If you want to cd to an absolute directory, you must include an escaped / (%2F) in the path. Example:
ftp://ftp.example.com/%2Fpub/ruby
This method will then return "/pub/ruby"
ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.