Sha256: dd698c5064ac108201c4da432c9cb6dc286cd28b914b1c34a514bcdb304c7481

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

# 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
markdown_exec-1.3.2 lib/globfiles.rb
markdown_exec-1.3.1 lib/globfiles.rb
markdown_exec-1.3.0 lib/globfiles.rb