lib/kamerling/message.rb in kamerling-0.0.1 vs lib/kamerling/message.rb in kamerling-0.0.2
- old
+ new
@@ -1,18 +1,18 @@
module Kamerling class Message
- KnownTypes = %w[DATA PING RGST RSLT]
UnknownType = Class.new RuntimeError
- def self.[](client: req(:client), payload: req(:payload),
- project: req(:project), task: req(:task), type: req(:type))
+ def self.[] client: req(:client), payload: req(:payload),
+ project: req(:project), task: req(:task), type: req(:type)
new "#{type}\0\0\0\0\0\0\0\0\0\0\0\0" + UUID.bin(client.uuid) +
UUID.bin(project.uuid) + UUID.bin(task.uuid) + payload
end
def initialize raw
@raw = raw
type = raw[0..3]
- raise UnknownType, type unless KnownTypes.include? type or type.empty?
+ known_types = %w(DATA PING RGST RSLT)
+ fail UnknownType, type unless known_types.include? type or type.empty?
end
def == other
raw == other.raw
end