Skip to content

Commit

Permalink
sort by modification time instead of filename stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gundamu-yunikon committed May 2, 2024
1 parent b1264bd commit a3df52f
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions lib/auspaynet/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

module Auspaynet
class Client
MONTHS = %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec].freeze

def initialize(host)
@host = host
@ftp = Net::FTP.new(@host)
Expand Down Expand Up @@ -41,17 +39,8 @@ def current_year

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

def file_for_month(filename:, file_format:)
month_from_filename = filename.gsub(/(#{filename}|#{file_format}|\W|\d)/, '')
month_number(month_from_filename)
end

def month_number(month_from_filename)
MONTHS.find_index(month_from_filename)
end
end
end

0 comments on commit a3df52f

Please sign in to comment.