Class: Glynn::Ftp

Inherits:
Object
  • Object
show all
Defined in:
lib/glynn/ftp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 21, options = Hash.new) ⇒ Ftp

Returns a new instance of Ftp.



7
8
9
10
11
12
# File 'lib/glynn/ftp.rb', line 7

def initialize(host, port = 21, options = Hash.new)
  options = {:username => nil, :password => nil}.merge(options)
  @host, @port = host, port
  @username, @password = options[:username], options[:password]
  @passive = options[:passive]
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/glynn/ftp.rb', line 5

def host
  @host
end

#passiveObject (readonly)

Returns the value of attribute passive.



5
6
7
# File 'lib/glynn/ftp.rb', line 5

def passive
  @passive
end

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/glynn/ftp.rb', line 5

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/glynn/ftp.rb', line 5

def port
  @port
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/glynn/ftp.rb', line 5

def username
  @username
end

Instance Method Details

#sync(local, distant) ⇒ Object



14
15
16
17
18
# File 'lib/glynn/ftp.rb', line 14

def sync(local, distant)
  connect do |ftp|
    send_dir(ftp, local, distant)
  end
end