teeworlds_network/lib/context.rb

30 lines
513 B
Ruby
Raw Permalink 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
2024-01-20 14:37:18 +00:00
@data.each_key do |key|
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