Module: MaxCube::Messages::TCP::Serializer::MessageZ

Defined in:
lib/maxcube/messages/tcp/type/z.rb

Overview

Wakeup command. Acknowledgement (A) follows.

Constant Summary

KEYS =

Mandatory hash keys.

%i[time scope].freeze
OPT_KEYS =

Optional hash keys.

%i[id].freeze

Instance Method Summary collapse

Instance Method Details

#serialize_tcp_z(hash) ⇒ Object (private)



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/maxcube/messages/tcp/type/z.rb', line 16

def serialize_tcp_z(hash)
  time = format('%02x', to_int(0, 'time', hash[:time]))
  scope = hash[:scope].to_sym
  scope = case scope
          when :group, :room
            'G'
          when :all
            'A'
          when :device
            'D'
          else
            raise InvalidMessageBody.new(@msg_type,
                                         "invalid scope: #{scope}")
          end
  args = [time, scope]
  args << format('%02x', to_int(0, 'ID', hash[:id])) if hash.key?(:id)
  args.join(',')
end