Class: Auspaynet::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/auspaynet/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
# File 'lib/auspaynet/client.rb', line 7

def initialize(host)
  @host = host
  @ftp = Net::FTP.new(@host)
  @ftp.
  @ftp.passive = true
end

Instance Method Details

#get(dir, filename) ⇒ Object



14
15
16
17
18
19
# File 'lib/auspaynet/client.rb', line 14

def get(dir, filename)
  @ftp.chdir(dir)
  @ftp.gettextfile(filename, nil)
ensure
  @ftp.chdir('/')
end

#list(dir:, matching_filename:, file_format: 'csv') ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/auspaynet/client.rb', line 21

def list(dir:, matching_filename:, file_format: 'csv')
  @ftp.chdir(dir)
  files = @ftp.nlst.select do |f|
    f.include?(matching_filename) && f.end_with?(file_format)
  end

  files.sort_by { |fname| @ftp.mtime(fname) }
ensure
  @ftp.chdir('/')
end