Sha256: 09407277c1bedb503df27d1307739c3e10057e2b2ea79c4058807f4264b42621

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

require_relative 'handler'
require 'maxcube/messages/serializer'

module MaxCube
  module Messages
    module UDP
      class Serializer
        include Handler
        include Messages::Serializer

        MSG_TYPES = %w[I N h c R].freeze

        MSG_PREFIX = (UDP::MSG_PREFIX + "*\x00").freeze

        def serialize_udp_hash(hash)
          check_udp_hash(hash)
          serial_number = hash[:serial_number] || '*' * 10
          msg = MSG_PREFIX + serial_number << @msg_type
          check_udp_msg(msg)
        end

        private

        def msg_msg_type(msg)
          msg[18]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
maxcube-client-0.4.1 lib/maxcube/messages/udp/serializer.rb
maxcube-client-0.4.0 lib/maxcube/messages/udp/serializer.rb