Sha256: 3cbe9f4898cdc8e76e6fbed9a620fac405d12b686c5368ef77aa811e3294aaae
Contents?: true
Size: 516 Bytes
Versions: 2
Compression:
Stored size: 516 Bytes
Contents
module FileScanner class Loader def initialize(path:, extensions: [], limit: -1) @path = File.expand_path(path) @extensions = extensions @limit = limit.to_i end def call paths = Dir.glob(files_path) return paths if @limit <= 0 paths.sample(@limit) end private def files_path File.join(@path, "**", extensions_path) end private def extensions_path return "*" if @extensions.empty? "*.{#{@extensions.join(",")}}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
file_scanner-2.3.0 | lib/file_scanner/loader.rb |
file_scanner-2.2.1 | lib/file_scanner/loader.rb |