Sha256: 96c9d4430c9d448d0adf438cbbeb57c8d2e526882c7b8dded182a24985c46463

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require "net/ftp"
require "Titania/version"


module Titania
  class Connection
    attr_accessor :connect

    def initialize(host,username,password)
      self.connect = Net::FTP::new(host, username, password)
    end

    def get_list(path = '/')

      # File List / Return Array
      result = self.connect.list(path)
    end

    def current_dir
      # get current dir
      self.connect.pwd
    end

    def change_dir(path)
      # Change dir
      self.connect.chdir(path)
    end


    def delete_file(path, file_name)
      # Delete file
      self.connect.delete(path + "/" + file_name)
    end


    def create_dir(path, dir_name)
      # Create dir

      self.connect.mkdir(path + "/" + dir_name)
    end


    def help(argv = nil)
      #  Help
      cmd = "HELP"
      if argv
        cmd = cmd + " " + argv
      end

      self.connect.sendcmd(cmd)

    end

    def change_name(f_name, c_name)
      # Change file or directory name
      self.connect.rename(f_name, c_name)
    end

    def remove_dir(dir)
      # Remove dir
      self.connect.rmdir(dir)
    end

    def file_size(file)
      # Get File Size
      self.connect.size(file)
    end

    def connection_status
      # Connection status
      if self.connect.closed?
        puts "Connection is closed !"
      else
        puts "Connection is active !"
      end
    end

    def close
      # close connection
      self.connect.close
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Titania-0.1.0 lib/Titania.rb