Class: Dir
- Inherits:
-
Object
- Object
- Dir
- Defined in:
- lib/time_extentions.rb
Instance Method Summary collapse
- #files_newer_than(limit) ⇒ Object
-
#files_older_than(limit) ⇒ Object
sweep directory of anything over a certain limit old.
- #sweep!(limit) ⇒ Object
Instance Method Details
#files_newer_than(limit) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/time_extentions.rb', line 60 def files_newer_than(limit) list = Array.new self.entries.each { |f| filename = File.join(path,f) next if File.directory?(filename) if File.open(filename).newer_than?(Date.today - limit) then #puts "File #{filename} is newer than limit" list << filename end } return list end |
#files_older_than(limit) ⇒ Object
sweep directory of anything over a certain limit old
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/time_extentions.rb', line 48 def files_older_than(limit) list = Array.new self.entries.each { |f| filename = File.join(path,f) next if File.directory?(filename) if File.open(filename).older_than?(Date.today - limit) then #puts "File #{filename} is older than limit" list << filename end } return list end |
#sweep!(limit) ⇒ Object
72 73 74 75 76 |
# File 'lib/time_extentions.rb', line 72 def sweep!(limit) files_older_than(limit).each { |f| File.delete(f) } end |