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

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(digest, lite = false) ⇒ DigestLite

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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