Class: Sphero::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/sphero/response.rb

Defined Under Namespace

Classes: GetAutoReconnect, GetBluetoothInfo, GetPowerState, GetRGB

Constant Summary collapse

SOP1 =
0
SOP2 =
1
MRSP =
2
SEQ =
3
DLEN =
4
CODE_OK =
0

Instance Method Summary collapse

Constructor Details

#initialize(header, body) ⇒ Response

Returns a new instance of Response.



11
12
13
14
# File 'lib/sphero/response.rb', line 11

def initialize header, body
  @header = header
  @body   = body
end

Instance Method Details

#bodyObject



28
29
30
# File 'lib/sphero/response.rb', line 28

def body
  @body.unpack 'C*'
end

#empty?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/sphero/response.rb', line 16

def empty?
  @header[DLEN] == 1
end

#seqObject



24
25
26
# File 'lib/sphero/response.rb', line 24

def seq
  @header[SEQ]
end

#success?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/sphero/response.rb', line 20

def success?
  @header[MRSP] == CODE_OK
end