Class: PgExport::FtpService::Connection

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/pg_export/ftp_service/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logger, logger

Constructor Details

#initialize(host:, user:, password:) ⇒ Connection

Returns a new instance of Connection.



8
9
10
11
# File 'lib/pg_export/ftp_service/connection.rb', line 8

def initialize(host:, user:, password:)
  @host, @user, @password = host, user, password
  open
end

Instance Attribute Details

#ftpObject (readonly)

Returns the value of attribute ftp.



6
7
8
# File 'lib/pg_export/ftp_service/connection.rb', line 6

def ftp
  @ftp
end

Instance Method Details

#closeObject



20
21
22
23
24
# File 'lib/pg_export/ftp_service/connection.rb', line 20

def close
  @ftp.close
  logger.info 'Close FTP'
  self
end

#openObject



13
14
15
16
17
18
# File 'lib/pg_export/ftp_service/connection.rb', line 13

def open
  @ftp = Net::FTP.new(host, user, password)
  @ftp.passive = true
  logger.info "Connect to #{host}"
  self
end