mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

We use only one sha type right now. Needed for https://github.com/Homebrew/brew/pull/10186
29 lines
446 B
Ruby
29 lines
446 B
Ruby
# typed: true
|
|
# frozen_string_literal: true
|
|
|
|
# A formula's checksum.
|
|
#
|
|
# @api private
|
|
class Checksum
|
|
extend Forwardable
|
|
|
|
attr_reader :hexdigest
|
|
|
|
def initialize(hexdigest)
|
|
@hexdigest = hexdigest.downcase
|
|
end
|
|
|
|
delegate [:empty?, :to_s, :length, :[]] => :@hexdigest
|
|
|
|
def ==(other)
|
|
case other
|
|
when String
|
|
to_s == other.downcase
|
|
when Checksum
|
|
hexdigest == other.hexdigest
|
|
else
|
|
false
|
|
end
|
|
end
|
|
end
|