Class: Grocer::ErrorResponse
- Inherits:
-
Object
- Object
- Grocer::ErrorResponse
- Defined in:
- lib/grocer/error_response.rb
Constant Summary collapse
- STATUS_CODE_DESCRIPTIONS =
{ 0 => 'No errors encountered', 1 => 'Processing error', 2 => 'Missing device token', 3 => 'Missing topic', 4 => 'Missing payload', 5 => 'Invalid token size', 6 => 'Invalid topic size', 7 => 'Invalid payload size', 8 => 'Invalid token', 256 => 'None (unknown)', }
- COMMAND =
8
Instance Attribute Summary collapse
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(binary_tuple) ⇒ ErrorResponse
constructor
A new instance of ErrorResponse.
- #status ⇒ Object
Constructor Details
#initialize(binary_tuple) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
20 21 22 23 24 25 26 27 |
# File 'lib/grocer/error_response.rb', line 20 def initialize(binary_tuple) # C => 1 byte command # C => 1 byte status # N => 4 byte identifier command, @status_code, @identifier = binary_tuple.unpack('CCN') raise InvalidFormatError unless @status_code && @identifier raise InvalidCommandError unless command == COMMAND end |
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
18 19 20 |
# File 'lib/grocer/error_response.rb', line 18 def identifier @identifier end |
#status_code ⇒ Object
Returns the value of attribute status_code.
18 19 20 |
# File 'lib/grocer/error_response.rb', line 18 def status_code @status_code end |
Instance Method Details
#status ⇒ Object
29 30 31 |
# File 'lib/grocer/error_response.rb', line 29 def status STATUS_CODE_DESCRIPTIONS[status_code] end |