Sha256: 8d530eb0af172bf6898788df235f8b3673d8513912b6dd9e259d1a11eba80e69
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
module MaxCube module Messages module TCP class Serializer module MessageT private # +count+ argument would cause ambuigity if it was optional # due to +rf_addresses+ has variable size KEYS = %i[count force rf_addresses].freeze # Command to delete one or more devices from the Cube # Acknowledgement (A) follows def serialize_tcp_t(hash) force = to_bool('force mode', hash[:force]) ? '1' : '0' rf_addresses = to_ints(0, 'RF addresses', *hash[:rf_addresses]) count = to_int(0, 'count', hash[:count]) unless count == rf_addresses.size raise InvalidMessageBody .new(@msg_type, 'count and number of devices mismatch: ' \ "#{count} != #{rf_addresses.size}") end if count.zero? raise InvalidMessageBody .new(@msg_type, 'no device specified') end addrs = encode(serialize(*rf_addresses, esize: 3)) [format('%02x', count), force, addrs].join(',') end 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/tcp/type/t.rb |
maxcube-client-0.4.0 | lib/maxcube/messages/tcp/type/t.rb |