Class: Twib::Response

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

Overview

A response from either twibd or a remote device.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_id, object_id, result_code, tag, payload, object_ids) ⇒ Response

Returns a new instance of Response.

Parameters:

  • device_id (Integer)

    ID of the device that this response originated from.

  • object_id (Integer)

    ID of the bridge object that this response originated from.

  • result_code (Integer)

    Result code

  • tag (Integer)

    Tag corresponding to the request that prompted this response.

  • payload (String)

    Raw data associated with the response

  • object_ids (Array<Integer>)

    Object IDs sent with the response



31
32
33
34
35
36
37
38
# File 'lib/twib.rb', line 31

def initialize(device_id, object_id, result_code, tag, payload, object_ids)
  @device_id = device_id
  @object_id = object_id
  @result_code = result_code
  @tag = tag
  @payload = payload
  @object_ids = object_ids
end

Instance Attribute Details

#device_idObject (readonly)

Returns the value of attribute device_id.



40
41
42
# File 'lib/twib.rb', line 40

def device_id
  @device_id
end

#object_idObject (readonly)

Returns the value of attribute object_id.



40
41
42
# File 'lib/twib.rb', line 40

def object_id
  @object_id
end

#object_idsObject (readonly)

Returns the value of attribute object_ids.



40
41
42
# File 'lib/twib.rb', line 40

def object_ids
  @object_ids
end

#payloadObject (readonly)

Returns the value of attribute payload.



40
41
42
# File 'lib/twib.rb', line 40

def payload
  @payload
end

#result_codeObject (readonly)

Returns the value of attribute result_code.



40
41
42
# File 'lib/twib.rb', line 40

def result_code
  @result_code
end

#tagObject (readonly)

Returns the value of attribute tag.



40
41
42
# File 'lib/twib.rb', line 40

def tag
  @tag
end

Instance Method Details

#assert_okself

Raises a Twib::ResultError if the #result_code is not OK.

Returns:

  • (self)

Raises:



45
46
47
48
49
50
# File 'lib/twib.rb', line 45

def assert_ok
  if @result_code != 0 then
    raise ResultError.new(@result_code)
  end
  return self
end