aboutsummaryrefslogtreecommitdiffstats
path: root/lib/uri/ftp.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-12 20:39:11 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-12 20:39:11 +0000
commite2b3183fc2c065f8aa9ae77f5ef7d0c8e29744af (patch)
treec968dc11a0fbf99ad2f6adcb249c7967e469bacb /lib/uri/ftp.rb
parent78e06ab19423518300a2ef9478cef69468e9d4a9 (diff)
downloadruby-e2b3183fc2c065f8aa9ae77f5ef7d0c8e29744af.tar.gz
* re.c (Init_Regexp): Document option constants. Patch by Vincent
Batts. [Ruby 1.9 - Bug #4677] * lib/uri/common.rb (module URI): Documentation for URI. Patch by Vincent Batts. [Ruby 1.9- Bug #4677] * lib/uri/ftp.rb (module URI): ditto * lib/uri/generic.rb (module URI): ditto * lib/uri/http.rb (module URI): ditto * lib/uri/https.rb (module URI): ditto * lib/uri/ldap.rb (module URI): ditto * lib/uri/ldaps.rb (module URI): ditto * lib/uri/mailto.rb (module URI): ditto * process.c (Init_process): Document Process constants. Patch by Vincent Batts. [Ruby 1.9- Bug #4677] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri/ftp.rb')
-rw-r--r--lib/uri/ftp.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb
index 4e33dadd33..663ecd5788 100644
--- a/lib/uri/ftp.rb
+++ b/lib/uri/ftp.rb
@@ -19,13 +19,18 @@ module URI
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
#
class FTP < Generic
+ # A Default port of 21 for URI::FTP
DEFAULT_PORT = 21
+ #
+ # An Array of the available components for URI::FTP
+ #
COMPONENT = [
:scheme,
:userinfo, :host, :port,
:path, :typecode
].freeze
+
#
# Typecode is "a", "i" or "d".
#
@@ -34,8 +39,19 @@ module URI
# * "d" indicates the contents of a directory should be displayed
#
TYPECODE = ['a', 'i', 'd'].freeze
+
+ # Typecode prefix
+ # ';type='
TYPECODE_PREFIX = ';type='.freeze
+ # alternate initialization
+ # Creates a new URI::FTP object.
+ #
+ # Unlike build(), this method does not escape the path component as required by
+ # RFC1738; instead it is treated as per RFC2396.
+ #
+ # Arguments are user, password, host, port, path, typecode,
+ # and arg_check, in that order.
def self.new2(user, password, host, port, path,
typecode = nil, arg_check = true)
typecode = nil if typecode.size == 0
@@ -133,8 +149,15 @@ module URI
end
end
end
+
+ # typecode accessor
+ #
+ # see URI::FTP::COMPONENT
attr_reader :typecode
+ # validates typecode +v+,
+ # returns a +true+ or +false+ boolean
+ #
def check_typecode(v)
if TYPECODE.include?(v)
return true
@@ -145,11 +168,39 @@ module URI
end
private :check_typecode
+ # private setter for the typecode +v+
+ #
+ # see also URI::FTP.typecode=
+ #
def set_typecode(v)
@typecode = v
end
protected :set_typecode
+ #
+ # == Args
+ #
+ # +v+::
+ # String
+ #
+ # == Description
+ #
+ # public setter for the typecode +v+.
+ # (with validation)
+ #
+ # see also URI::FTP.check_typecode
+ #
+ # == Usage
+ #
+ # require 'uri'
+ #
+ # uri = URI.parse("ftp://john@ftp.example.com/my_file.img")
+ # #=> #<URI::FTP:0x00000000923650 URL:ftp://john@ftp.example.com/my_file.img>
+ # uri.typecode = "i"
+ # # => "i"
+ # uri
+ # #=> #<URI::FTP:0x00000000923650 URL:ftp://john@ftp.example.com/my_file.img;type=i>
+ #
def typecode=(typecode)
check_typecode(typecode)
set_typecode(typecode)