Class: Mmi::ContentHash::Sha512

Inherits:
Base
  • Object
show all
Defined in:
lib/mmi/content_hash/sha512.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hex_digest) ⇒ Sha512

Returns a new instance of Sha512.



10
11
12
13
14
# File 'lib/mmi/content_hash/sha512.rb', line 10

def initialize(hex_digest)
	super()
	
	self.hex_digest = hex_digest
end

Instance Attribute Details

#hex_digestObject

Returns the value of attribute hex_digest.



8
9
10
# File 'lib/mmi/content_hash/sha512.rb', line 8

def hex_digest
  @hex_digest
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
# File 'lib/mmi/content_hash/sha512.rb', line 20

def ==(other)
	self.class == other.class && self.hex_digest == other.hex_digest
end

#match_file?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mmi/content_hash/sha512.rb', line 16

def match_file?(file_path)
	Digest::SHA512.hexdigest(File.read(file_path)) == self.hex_digest
end