Class: URI::FTP
Overview
RFC1738 section 3.2.
Constant Summary collapse
- DEFAULT_PORT =
21
- COMPONENT =
[ :scheme, :userinfo, :host, :port, :path, :typecode ].freeze
- TYPECODE =
Typecode is, "a", "i" or "d". As for "a" the text, as for "i" binary, as for "d" the directory is displayed. "A" with the text, as for "i" being binary, is because the respective data type was called ASCII and IMAGE with the protocol of FTP.
['a', 'i', 'd'].freeze
- TYPECODE_PREFIX =
';type='.freeze
Constants inherited from Generic
Constants included from REGEXP
REGEXP::ABS_PATH, REGEXP::ABS_URI, REGEXP::ABS_URI_REF, REGEXP::ESCAPED, REGEXP::FRAGMENT, REGEXP::HOST, REGEXP::OPAQUE, REGEXP::PORT, REGEXP::QUERY, REGEXP::REGISTRY, REGEXP::REL_PATH, REGEXP::REL_URI, REGEXP::REL_URI_REF, REGEXP::SCHEME, REGEXP::UNSAFE, REGEXP::URI_REF, REGEXP::USERINFO
Constants included from URI
Instance Attribute Summary collapse
-
#typecode ⇒ Object
Returns the value of attribute typecode.
Attributes inherited from Generic
#fragment, #host, #opaque, #path, #port, #query, #registry, #scheme
Class Method Summary collapse
-
.build(args) ⇒ Object
Description.
- .new2(user, password, host, port, path, typecode = nil, arg_check = true) ⇒ Object
Instance Method Summary collapse
-
#initialize(*arg) ⇒ FTP
constructor
Description.
-
#merge(oth) ⇒ Object
:nodoc:.
- #to_s ⇒ Object
Methods inherited from Generic
#==, #absolute?, build2, #coerce, component, #component, #default_port, default_port, #eql?, #hash, #hierarchical?, #inspect, #merge!, #normalize, #normalize!, #password, #password=, #relative?, #route_from, #route_to, #select, use_registry, #user, #user=, #userinfo, #userinfo=
Methods included from URI
extract, join, parse, regexp, split
Methods included from Escape
Constructor Details
#initialize(*arg) ⇒ FTP
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/uri/ftp.rb', line 86 def initialize(*arg) super(*arg) @typecode = nil tmp = @path.index(TYPECODE_PREFIX) if tmp typecode = @path[tmp + TYPECODE_PREFIX.size..-1] self.set_path(@path[0..tmp - 1]) if arg[-1] self.typecode = typecode else self.set_typecode(typecode) end end end |
Instance Attribute Details
#typecode ⇒ Object
Returns the value of attribute typecode
101 102 103 |
# File 'lib/uri/ftp.rb', line 101 def typecode @typecode end |
Class Method Details
.build(args) ⇒ Object
Description
Creates a new URI::FTP object from components of URI::FTP with check. It is scheme, userinfo, host, port, path and typecode. It provided by an Array or a Hash. typecode is "a", "i" or "d".
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/uri/ftp.rb', line 59 def self.build(args) tmp = Util::make_components_hash(self, args) if tmp[:typecode] if tmp[:typecode].size == 1 tmp[:typecode] = TYPECODE_PREFIX + tmp[:typecode] end tmp[:path] << tmp[:typecode] end return super(tmp) end |
.new2(user, password, host, port, path, typecode = nil, arg_check = true) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/uri/ftp.rb', line 35 def self.new2(user, password, host, port, path, typecode = nil, arg_check = true) typecode = nil if typecode.size == 0 if typecode && !TYPECODE.include?(typecode) raise ArgumentError, "bad typecode is specified: #{typecode}" end # do escape self.new('ftp', [user, password], host, port, nil, typecode ? path + TYPECODE_PREFIX + typecode : path, nil, nil, nil, arg_check) end |
Instance Method Details
#merge(oth) ⇒ Object
:nodoc:
124 125 126 127 128 129 130 131 |
# File 'lib/uri/ftp.rb', line 124 def merge(oth) # :nodoc: tmp = super(oth) if self != tmp tmp.set_typecode(oth.typecode) end return tmp end |
#to_s ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/uri/ftp.rb', line 133 def to_s save_path = nil if @typecode save_path = @path @path = @path + TYPECODE_PREFIX + @typecode end str = super if @typecode @path = save_path end return str end |