Class: Puppet::Util::Checksums::DigestLite

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/checksums.rb

Instance Method Summary collapse

Constructor Details

#initialize(digest, lite = false) ⇒ DigestLite

Returns a new instance of DigestLite.



343
344
345
346
347
# File 'lib/puppet/util/checksums.rb', line 343

def initialize(digest, lite = false)
  @digest = digest
  @lite = lite
  @bytes = 0
end

Instance Method Details

#<<(str) ⇒ Object

Provide an interface for digests. If lite, only digest the first 512 bytes



350
351
352
353
354
355
356
357
358
359
360
# File 'lib/puppet/util/checksums.rb', line 350

def <<(str)
  if @lite
    if @bytes < 512
      buf = str[0, 512 - @bytes]
      @digest << buf
      @bytes += buf.length
    end
  else
    @digest << str
  end
end