Sha256: b2af9a9a7edcc19112a803bcdeff0b6a50132eaa4b3fc6eb42de749fc500b00c
Contents?: true
Size: 905 Bytes
Versions: 17
Compression:
Stored size: 905 Bytes
Contents
require "file_scanner/refinements" module FileScanner using Refinements module Filters def self.defaults constants.map do |name| self.const_get(name).new end end class LastAccess DAY = 3600*24 def initialize(atime = Time.now-30*DAY) @atime = atime end def call(file) @atime >= File.atime(file) end end class MatchingName def initialize(regexp = nil) @regexp = compile(regexp) end def call(file) return unless @regexp File.basename(file).matches?(@regexp) end private def compile(regexp) return unless regexp Regexp.compile(regexp.to_s) end end class SizeRange def initialize(min: 0, max: 5*1024) @range = min..max end def call(file) @range === File.size(file) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems