Class: Aardi::ContentHashes

Inherits:
Object
  • Object
show all
Defined in:
lib/aardi/content_hashes.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ContentHashes

Returns a new instance of ContentHashes.



5
6
7
8
# File 'lib/aardi/content_hashes.rb', line 5

def initialize(path)
  @path = path
  read_hashes
end

Instance Method Details

#[](path) ⇒ Object



10
11
12
# File 'lib/aardi/content_hashes.rb', line 10

def [](path)
  @hashes[path]
end

#[]=(path, hash) ⇒ Object



14
15
16
# File 'lib/aardi/content_hashes.rb', line 14

def []=(path, hash)
  @hashes[path] = hash
end

#writeObject



18
19
20
21
22
23
# File 'lib/aardi/content_hashes.rb', line 18

def write
  return if new_hashes == @original_hashes

  File.write(@path, @new_hashes)
  puts "Wrote: #{@path}\n"
end