Class: Filewatcher::Snapshot

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/filewatcher/snapshot.rb

Overview

Class for snapshots of file system

Instance Method Summary collapse

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