class MarkdownExec::SavedFilesMatcher


most recent files.
It can list all matching files, retrieve the most recent file, or a list of
This class is responsible for matching saved files based on the given pattern.
SavedFilesMatcher

def self.list_all(folder, glob)

Lists all files in the specified folder that match the given glob pattern
def self.list_all(folder, glob)
  Dir.glob(File.join(folder, glob))
end

def self.most_recent(folder, glob, arr = nil)

Retrieves the most recent file from the specified folder that matches the given glob pattern
def self.most_recent(folder, glob, arr = nil)
  arr = list_all(folder, glob) if arr.nil?
  return if arr.count < 1
  arr.max
end

def self.most_recent_list(folder, glob, list_count, arr = nil)

that match the given glob pattern
Retrieves a list of the most recent files (up to list_count) from the specified folder
def self.most_recent_list(folder, glob, list_count, arr = nil)
  arr = list_all(folder, glob) if arr.nil?
  return if arr.empty?
  arr.sort[-[arr.count, list_count].min..].reverse
end