Module: Shrine::Plugins::Signature::ClassMethods

Defined in:
lib/shrine/plugins/signature.rb

Instance Method Summary collapse

Instance Method Details

#calculate_signature(io, algorithm, format: :hex, rewind: true) ⇒ Object Also known as: signature

Calculates `algorithm` hash of the contents of the IO object, and encodes it into `format`.


24
25
26
27
28
29
30
31
# File 'lib/shrine/plugins/signature.rb', line 24

def calculate_signature(io, algorithm, format: :hex, rewind: true)
  calculator = SignatureCalculator.new(algorithm.downcase, format: format)

  signature = instrument_signature(io, algorithm, format) { calculator.call(io) }
  io.rewind if rewind

  signature
end