Class: Filewatcher::Snapshot
- Inherits:
-
Object
- Object
- Filewatcher::Snapshot
- Extended by:
- Forwardable
- Defined in:
- lib/filewatcher/snapshot.rb
Overview
Class for snapshots of file system
Instance Method Summary collapse
- #-(other) ⇒ Object
-
#initialize(filenames) ⇒ Snapshot
constructor
A new instance of Snapshot.
Constructor Details
#initialize(filenames) ⇒ Snapshot
Returns a new instance of Snapshot.
11 12 13 14 15 |
# File 'lib/filewatcher/snapshot.rb', line 11 def initialize(filenames) @data = filenames.each_with_object({}) do |filename, data| data[filename] = SnapshotFile.new(filename) end end |
Instance Method Details
#-(other) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/filewatcher/snapshot.rb', line 17 def -(other) changes = {} each do |filename, snapshot_file| changes[filename] = snapshot_file - other[filename] end other.each do |filename, _snapshot_file| changes[filename] = :deleted unless self[filename] end changes.tap(&:compact!) end |