build(args) public


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
Show source
Register or log in to add new notes.