2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-08-17 02:58:03 +02:00
|
|
|
# A formula's checksum.
|
|
|
|
#
|
|
|
|
# @api private
|
2012-06-18 19:58:35 -05:00
|
|
|
class Checksum
|
2017-06-26 07:30:28 +02:00
|
|
|
extend Forwardable
|
|
|
|
|
2012-06-18 19:58:35 -05:00
|
|
|
attr_reader :hash_type, :hexdigest
|
|
|
|
|
2016-09-17 15:17:27 +01:00
|
|
|
TYPES = [:sha256].freeze
|
2012-06-18 19:58:35 -05:00
|
|
|
|
2013-04-07 00:49:56 -05:00
|
|
|
def initialize(hash_type, hexdigest)
|
|
|
|
@hash_type = hash_type
|
|
|
|
@hexdigest = hexdigest
|
2012-06-18 19:58:35 -05:00
|
|
|
end
|
|
|
|
|
2017-06-26 07:30:28 +02:00
|
|
|
delegate [:empty?, :to_s] => :@hexdigest
|
2012-06-18 19:58:35 -05:00
|
|
|
|
2013-04-07 00:49:56 -05:00
|
|
|
def ==(other)
|
2018-03-24 09:04:51 -04:00
|
|
|
hash_type == other&.hash_type && hexdigest == other.hexdigest
|
2012-06-18 19:58:35 -05:00
|
|
|
end
|
|
|
|
end
|