teeworlds_network/lib/context.rb

30 lines
517 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Context
attr_reader :old_data
2022-11-26 10:25:23 +00:00
attr_accessor :data, :message
2022-11-26 10:25:23 +00:00
def initialize(message, keys = {})
@message = message # the obj holding the parsed chunk
@cancel = false
@old_data = keys
@data = keys
end
def verify
@data.each do |key, _value|
next if @old_data.key? key
raise "Error: invalid data key '#{key}'\n valid keys: #{@old_data.keys}"
end
end
def canceld?
@cancel
end
def cancel
@cancel = true
end
end