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.
12 13 14 15 16 |
# File 'lib/filewatcher/snapshot.rb', line 12 def initialize(filenames) @data = filenames.each_with_object({}) do |filename, data| data[filename] = SnapshotFile.new(filename) end end |
Instance Method Details
#-(other) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/filewatcher/snapshot.rb', line 18 def -(other) changes = {} each do |filename, snapshot_file| changes[filename] = snapshot_file - other[filename] end other.each_key do |filename| changes[filename] = :deleted unless self[filename] end changes.tap(&:compact!) end |