Class: DropboxContentHasher::Calculator

Inherits:
Object
  • Object
show all
Defined in:
lib/dropbox_content_hasher/calculator.rb

Defined Under Namespace

Classes: FileDoesNotExist

Constant Summary collapse

BLOCK_SIZE =
(4 * 1024 * 1024).to_f.freeze

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Calculator

Returns a new instance of Calculator.



7
8
9
# File 'lib/dropbox_content_hasher/calculator.rb', line 7

def initialize(path)
  @file = Pathname.new(path)
end

Instance Method Details

#content_hashObject

Raises:



11
12
13
14
15
# File 'lib/dropbox_content_hasher/calculator.rb', line 11

def content_hash
  raise FileDoesNotExist unless @file.exist?

  Digest::SHA256.hexdigest(hashes.join)
end