Class: FSEvents::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/fsevents/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, path, stream) ⇒ Event

Returns a new instance of Event.



5
6
7
8
9
# File 'lib/fsevents/event.rb', line 5

def initialize(id, path, stream)
  @id     = id
  @path   = path.sub(%r%/$%, '')
  @stream = stream
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/fsevents/event.rb', line 3

def id
  @id
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/fsevents/event.rb', line 3

def path
  @path
end

#streamObject (readonly)

Returns the value of attribute stream.



3
4
5
# File 'lib/fsevents/event.rb', line 3

def stream
  @stream
end

Instance Method Details

#filesObject



11
12
13
# File 'lib/fsevents/event.rb', line 11

def files
  Dir["#{path}/*"]
end

#modified_filesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fsevents/event.rb', line 15

def modified_files
  case stream.mode
  when :mtime
    files.select { |f|  File.mtime(f) >= stream.last_event }
  when :cache
    cache = stream.dirs[path] || {}
    
    files.select do |f|
      cached = cache[f]
      
      cached.nil? or
      
      File.mtime(f) != cached.mtime or
      File.size(f)  != cached.size
    end
  end
end