Sha256: 9f38e13147b450de8cb977b9b2959300fc05bba652339a96274d9efa4270f928

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

require 'digest'

module Digest
  class Simple < Class
    VERSION = "1.0.0"

    def initialize
      @buffer = ""
    end

    def reset
      @buffer.clear
      self
    end

    def update(str)
      @buffer += str
      self
    end
    alias << update

    def digest(str=nil)
      if str
        reset
        update(str)
        v = finish
        reset
        v
      else
        dup.send :finish
      end
    end

    def block_length
      0
    end

    private

    def finish
      fail NotImplementedError, "must be defined finish method"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
digest-simple-1.0.0 lib/digest/simple.rb