Class: Crate::Digest
- Inherits:
-
Object
- Object
- Crate::Digest
- Defined in:
- lib/crate/digest.rb
Overview
A wrapper around a given digest value and the algorithm that creates it. Use it to verify a bytestream.
Instance Attribute Summary collapse
-
#engine ⇒ Object
readonly
Returns the value of attribute engine.
-
#hex ⇒ Object
readonly
Returns the value of attribute hex.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hex, klass) ⇒ Digest
constructor
A new instance of Digest.
-
#valid?(filename) ⇒ Boolean
verify that the given filename has a digest value.
Constructor Details
#initialize(hex, klass) ⇒ Digest
Returns a new instance of Digest.
24 25 26 27 |
# File 'lib/crate/digest.rb', line 24 def initialize( hex, klass ) @hex = hex @engine = klass.new end |
Instance Attribute Details
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
11 12 13 |
# File 'lib/crate/digest.rb', line 11 def engine @engine end |
#hex ⇒ Object (readonly)
Returns the value of attribute hex.
12 13 14 |
# File 'lib/crate/digest.rb', line 12 def hex @hex end |
Class Method Details
Instance Method Details
#valid?(filename) ⇒ Boolean
verify that the given filename has a digest value
32 33 34 |
# File 'lib/crate/digest.rb', line 32 def valid?( filename ) engine.hexdigest( IO.read( filename ) ) == hex end |