Class: DropboxContentHasher::Calculator
- Inherits:
-
Object
- Object
- DropboxContentHasher::Calculator
- 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
- #content_hash ⇒ Object
-
#initialize(path) ⇒ Calculator
constructor
A new instance of Calculator.
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_hash ⇒ Object
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 |