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.



242
243
244
245
246
# File 'lib/puppet/util/checksums.rb', line 242

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



249
250
251
252
253
254
255
256
257
258
259
# File 'lib/puppet/util/checksums.rb', line 249

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