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


323
324
325
326
327
# File 'lib/puppet/util/checksums.rb', line 323

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


330
331
332
333
334
335
336
337
338
339
340
# File 'lib/puppet/util/checksums.rb', line 330

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