Sha256: 18839759fe259ad28bffcdc204ff9fbea8e6666d1b063ff38156c10c6c3867d4
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module MaxCube module Messages module TCP class Serializer # Wakeup command. # Acknowledgement (A) follows. module MessageZ private # Mandatory hash keys. KEYS = %i[time scope].freeze # Optional hash keys. OPT_KEYS = %i[id].freeze 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 end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
maxcube-client-0.5.1 | lib/maxcube/messages/tcp/type/z.rb |
maxcube-client-0.5.0 | lib/maxcube/messages/tcp/type/z.rb |