1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
class Checksum attr_reader :hash_type, :hexdigest TYPES = [:md5, :sha1, :sha256] 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