lib/hastings/fs/dir.rb
# Instantiates all the entries in a directory into their respective
# {Hastings::File} and {Hastings::Dir} objects.
#
# To filter by methods, you can pass arguments of methods expected to be
# truthy. They are run in order given in the hash.
# @example Files and directories newer than 5 minutes ago
#   dir.list("*", :newer_than? => Time.now - 5*60)
#
# @param str [String] following the {::Dir#glob} format
# @param args [Hash] methods to be filtered by when truthy
# @return [Array[Hastings::File|Hastings::Dir]] a list of entries in the
#   directory, instantiated to files or directories
Instantiates all the entries in a directory into their respective
{Hastings::File} and {Hastings::Dir} objects.

To filter by methods, you can pass arguments of methods expected to be
truthy. They are run in order given in the hash.
Instantiates all the entries in a directory into their respective { Hastings :: File } and { Hastings :: Dir } objects . To filter by methods you can pass arguments of methods expected to be truthy . They are run in order given in the hash .
def list(str = nil, **args)
      args.inject(instantiate_list glob(str)) do |entries, (method, arg)|
        entries.select { |f| f.public_send(method, *Array(arg)) }
      end
    end
def list ( str = nil , ** args ) args . inject ( instantiate_list glob ( str ) ) do | entries , ( method , arg ) | entries . select { | f | f . public_send ( method , * Array ( arg ) ) } end end
Instantiates all the entries in a directory into their respective
{Hastings::File} and {Hastings::Dir} objects.
Instantiates all the entries in a directory into their respective { Hastings :: File } and { Hastings :: Dir } objects .
] a list of entries in the directory, instantiated to files or directories
] a list of entries in the directory instantiated to files or directories
Array[Hastings::File|Hastings::Dir
str
following the {::Dir#glob} format
following the { :: Dir#glob } format
args
methods to be filtered by when truthy
methods to be filtered by when truthy
example
Files and directories newer than 5 minutes ago dir.list("*", :newer_than.
Files and directories newer than 5 minutes ago dir . list ( " * " : newer_than .