15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/cbor-diagnostic-app/hash.rb', line 15
def self.decode(_, s)
if CBOR::Sequence === s
args = s.elements
else
args = [s]
end
case args
in [String]
args[1] = -16 in [String, Integer | String]
else
raise ArgumentError.new("cbor-diagnostic: hash<< #{args.inspect[1...-1]} >>: Argument Error")
end
fn = HASHES[args[1]]
if fn
fn.digest(args[0])
else
raise ArgumentError.new("cbor-diagnostic: hash<<>>: unimplemented hash function #{args[1]}")
end
end
|