Module: FunWith::Files::DigestMethods

Defined in:
lib/fun_with/files/digest_methods.rb

Instance Method Summary collapse

Instance Method Details

#digest(digest_class = Digest::MD5) ⇒ Object



32
33
34
# File 'lib/fun_with/files/digest_methods.rb', line 32

def digest( digest_class = Digest::MD5 )
  self.file? ? digest_class.hexdigest( self.read ) : ""
end

#md5Object



4
5
6
# File 'lib/fun_with/files/digest_methods.rb', line 4

def md5
  digest( Digest::MD5 )
end

#sha1Object



8
9
10
# File 'lib/fun_with/files/digest_methods.rb', line 8

def sha1
  digest( Digest::SHA1 )
end

#sha2Object



12
13
14
# File 'lib/fun_with/files/digest_methods.rb', line 12

def sha2
  digest( Digest::SHA2 )
end

#sha224Object



16
17
18
# File 'lib/fun_with/files/digest_methods.rb', line 16

def sha224
  digest( Digest::SHA224 )
end

#sha256Object



20
21
22
# File 'lib/fun_with/files/digest_methods.rb', line 20

def sha256
  digest( Digest::SHA256 )
end

#sha384Object



24
25
26
# File 'lib/fun_with/files/digest_methods.rb', line 24

def sha384
  digest( Digest::SHA384 )
end

#sha512Object



28
29
30
# File 'lib/fun_with/files/digest_methods.rb', line 28

def sha512
  digest( Digest::SHA512 )
end