Class: Tus::Checksum
- Inherits:
-
Object
- Object
- Tus::Checksum
- Defined in:
- lib/tus/checksum.rb
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
Instance Method Summary collapse
- #generate(content) ⇒ Object
-
#initialize(algorithm) ⇒ Checksum
constructor
A new instance of Checksum.
- #match?(checksum, content) ⇒ Boolean
Constructor Details
#initialize(algorithm) ⇒ Checksum
Returns a new instance of Checksum.
9 10 11 |
# File 'lib/tus/checksum.rb', line 9 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 |
Instance Method Details
#generate(content) ⇒ Object
18 19 20 |
# File 'lib/tus/checksum.rb', line 18 def generate(content) send("generate_#{algorithm}", content) end |
#match?(checksum, content) ⇒ Boolean
13 14 15 16 |
# File 'lib/tus/checksum.rb', line 13 def match?(checksum, content) checksum = Base64.decode64(checksum) generate(content) == checksum end |