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.


338
339
340
341
342
# File 'lib/puppet/util/checksums.rb', line 338

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


345
346
347
348
349
350
351
352
353
354
355
# File 'lib/puppet/util/checksums.rb', line 345

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