2012-06-18 19:58:35 -05:00
|
|
|
class Checksum
|
|
|
|
attr_reader :hash_type, :hexdigest
|
|
|
|
|
2013-01-26 13:03:22 +00:00
|
|
|
TYPES = [:sha1, :sha256]
|
2012-06-18 19:58:35 -05:00
|
|
|
|
|
|
|
def initialize type=:sha1, val=nil
|
|
|
|
@hash_type = type
|
|
|
|
@hexdigest = val.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def empty?
|
|
|
|
@hexdigest.empty?
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
@hexdigest
|
|
|
|
end
|
|
|
|
|
|
|
|
def == other
|
|
|
|
@hash_type == other.hash_type and @hexdigest == other.hexdigest
|
|
|
|
end
|
|
|
|
end
|