Class: Tus::Checksum
- Inherits:
-
Object
- Object
- Tus::Checksum
- Defined in:
- lib/tus/checksum.rb
Constant Summary collapse
- CHUNK_SIZE =
16*1024
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
Class Method Summary collapse
Instance Method Summary collapse
- #generate(io) ⇒ Object
-
#initialize(algorithm) ⇒ Checksum
constructor
A new instance of Checksum.
- #match?(checksum, io) ⇒ Boolean
Constructor Details
#initialize(algorithm) ⇒ Checksum
Returns a new instance of Checksum.
13 14 15 |
# File 'lib/tus/checksum.rb', line 13 def initialize(algorithm) @algorithm = algorithm end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
7 8 9 |
# File 'lib/tus/checksum.rb', line 7 def algorithm @algorithm end |
Class Method Details
.generate(algorithm, input) ⇒ Object
9 10 11 |
# File 'lib/tus/checksum.rb', line 9 def self.generate(algorithm, input) new(algorithm).generate(input) end |
Instance Method Details
#generate(io) ⇒ Object
21 22 23 24 25 |
# File 'lib/tus/checksum.rb', line 21 def generate(io) hash = send("generate_#{algorithm}", io) io.rewind hash end |
#match?(checksum, io) ⇒ Boolean
17 18 19 |
# File 'lib/tus/checksum.rb', line 17 def match?(checksum, io) generate(io) == checksum end |