# frozen_string_literal: true # encoding=utf-8 # require 'json' # require 'yaml' # require_relative 'env' # include Env ## directory listing of saved files matching glob # class Globfiles def initialize(folder, glob) @folder = folder @glob = glob end def list_all Dir.glob(File.join(@folder, @glob)).tap_inspect end ## single most recent item # def most_recent(arr = nil) arr = list_all if arr.nil? return if arr.count < 1 arr.max.tap_inspect end ## multiple recent items # def most_recent_list(list_count, arr = nil) arr = list_all if arr.nil? return if (ac = arr.count) < 1 arr.sort[-[ac, list_count].min..].reverse.tap_inspect end end # class Globfiles