Skip to content

Commit

Permalink
get rid of all the date code
Browse files Browse the repository at this point in the history
  • Loading branch information
gundamu-yunikon committed May 2, 2024
1 parent 0a61a70 commit 01ed604
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions lib/auspaynet/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,12 @@ def get(dir, filename)
def list(dir:, matching_filename:, file_format: 'csv')
@ftp.chdir(dir)
files = @ftp.nlst.select do |f|
f.include?(matching_filename) &&
f.include?(file_format) &&
(f.include?("#{current_year}-") || f.include?("#{current_year})"))
f.include?(matching_filename) && f.end_with?(file_format)
end

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

private

def current_year
Time.now.strftime('%y')
end

def extract_latest_files(files:, _file_format:)
files.sort_by do |filename|
@ftp.mtime(filename)
end
end
end
end

0 comments on commit 01ed604

Please sign in to comment.