Class: ModifiedFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/filters/modified_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_class, last_modified = nil) ⇒ ModifiedFilter

Returns a new instance of ModifiedFilter.


3
4
5
6
7
# File 'lib/filters/modified_filter.rb', line 3

def initialize(file_class, last_modified = nil)
  @file_class = file_class
  @last_modified = last_modified
  @modifieds = []
end

Instance Method Details

#completeObject


16
17
18
19
# File 'lib/filters/modified_filter.rb', line 16

def complete
  @last_modified = @modifieds.max
  @modifieds = []
end

#filter(path) ⇒ Object


9
10
11
12
13
14
# File 'lib/filters/modified_filter.rb', line 9

def filter(path)
  modified = @file_class.mtime(path)
  @modifieds << modified
  
  return @last_modified.nil? || modified > @last_modified
end