Class: Dap::Filter::FilterDigest

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/dap/filter/simple.rb

Instance Attribute Summary

Attributes included from Base

#name, #opts

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#process(doc) ⇒ Object



533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/dap/filter/simple.rb', line 533

def process(doc)
  self.opts.each_pair do |k,v|
    if doc.has_key?(k)
      case v
      when 'sha1'
        doc["#{k}.sha1"] = Digest::SHA1.hexdigest(doc[k].to_s)
      when 'md5'
        doc["#{k}.md5"] = Digest::MD5.hexdigest(doc[k].to_s)
      when 'sha256'
        doc["#{k}.sha256"] = Digest::SHA256.hexdigest(doc[k].to_s)
      end
    end
  end
 [ doc ]
end