31: def process(packet)
32: @init.call(Net::SSH::Packet.new(packet.to_s)) if @init
33: type = packet.read_byte
34: raise "expected #{@type}, but got #{type}" if @type != type
35:
36: @data.zip(types).each do |expected, type|
37: type ||= case expected
38: when nil then break
39: when Numeric then :long
40: when String then :string
41: when TrueClass, FalseClass then :bool
42: end
43:
44: actual = packet.send("read_#{type}")
45: next if expected.nil?
46: raise "expected #{type} #{expected.inspect} but got #{actual.inspect}" unless expected == actual
47: end
48: end