class SpheroPwn::Response

Superclass for all messages sent from the robot in response to commands.

Constants

RESPONSE_CODES

@return {Hash<Integer, Symbol>} maps error codes to symbols

Attributes

code[R]

@return {Symbol} the command's response

data_bytes[R]

@return {Array<Number>} the additional payload bytes in the response; this

array is frozen
sequence[R]

@return {Number} the sequence number matching the response to its command

Public Class Methods

new(code_byte, sequence_byte, data_bytes) click to toggle source

Parses a response to a command.

@param {Number} code_byte the response code number @param {Number} sequence_byte the sequence number matching the response to

its command

@param {Array<Number>} data_bytes the additional response payload; can be

empty, cannot be nil; the constructor takes ownership of the array and
freezes it
# File lib/sphero_pwn/response.rb, line 21
def initialize(code_byte, sequence_byte, data_bytes)
  @code = RESPONSE_CODES[code_byte] || :unknown
  @sequence = sequence_byte
  @data_bytes = data_bytes.freeze
end