# URI::FTP (Class)

In: | uri/ftp.rb
Parent: | Generic

RFC1738 section 3.2.

## Methods

build merge new new2 to_s typecode=

## Constants

DEFAULT_PORT | = | 21
COMPONENT | = | [ :scheme, :userinfo, :host, :port, :path, :typecode
TYPECODE | = | ['a', 'i', 'd'].freeze
TYPECODE_PREFIX | = | ';type='.freeze

## Attributes

typecode | [R] |

## Public Class methods

new2(user, password, host, port, path, typecode = nil, arg_check = true)

[Source]

    # File uri/ftp.rb, line 50
        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

build(args)

[Source]

    # File uri/ftp.rb, line 67
        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

new(*arg)

[Source]

    # File uri/ftp.rb, line 80
        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

## Public Instance methods

typecode=(typecode)

[Source]

    # File uri/ftp.rb, line 116
        def typecode=(typecode)
          check_typecode(typecode)
          set_typecode(typecode)
          typecode
        end

merge(oth)

[Source]

    # File uri/ftp.rb, line 124
        def merge(oth)
          tmp = super(oth)
          if self != tmp
            tmp.set_typecode(oth.typecode)
          end

          return tmp
        end

to_s()

[Source]

    # File uri/ftp.rb, line 135
        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

[Validate]