Sha256: 4b557f51fc4446c269fe8eacfbd182bee3211b23f4ef93f5f66391548192210f
Contents?: true
Size: 632 Bytes
Versions: 3
Compression:
Stored size: 632 Bytes
Contents
require 'miu/errors' require 'msgpack' module Miu class Packet attr_accessor :tag, :data def initialize(tag, data) @tag = tag @data = data end def dump [@tag.to_s, @data.to_msgpack] end def self.load(parts) tag = parts[0] data = MessagePack.unpack(parts[1]) new tag, data rescue => e raise PacketLoadError, e end def to_s "<#{tag}> #{data.to_h}" end def inspect inspection = [:tag, :data].map do |name| "#{name}: #{__send__(name).inspect}" end.join(', ') "#<#{self.class} #{inspection}>" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
miu-0.2.3 | lib/miu/packet.rb |
miu-0.2.2 | lib/miu/packet.rb |
miu-0.2.1 | lib/miu/packet.rb |