Class: FSEvents::Event
- Inherits:
-
Object
- Object
- FSEvents::Event
- Defined in:
- lib/fsevents/event.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #deleted_files ⇒ Object
- #files ⇒ Object
-
#initialize(id, path, stream) ⇒ Event
constructor
A new instance of Event.
- #modified_files ⇒ Object
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
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/fsevents/event.rb', line 3 def id @id end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/fsevents/event.rb', line 3 def path @path end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
3 4 5 |
# File 'lib/fsevents/event.rb', line 3 def stream @stream end |
Instance Method Details
#deleted_files ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fsevents/event.rb', line 33 def deleted_files case stream.mode when :mtime raise RuntimeError, 'This mode does not support getting deleted files' when :cache cache = stream.dirs[path] || {} cache.keys - files end end |
#files ⇒ Object
11 12 13 |
# File 'lib/fsevents/event.rb', line 11 def files Dir["#{path}/*"] end |
#modified_files ⇒ Object
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 |