Class: SDN::Message::Nack
- Inherits:
-
Message
- Object
- Message
- SDN::Message::Nack
- Defined in:
- lib/sdn/message.rb
Overview
Negative acknowledgement response emitted when a request cannot be fulfilled.
Constant Summary collapse
- MSG =
Protocol message number
0x6f- PARAMS_LENGTH =
Number of protocol parameter bytes expected
1- VALUES =
Mapping from symbolic error names to SDN error codes.
{ data_error: 0x01, unknown_message: 0x10, node_is_locked: 0x20, wrong_position: 0x21, limits_not_set: 0x22, ip_not_set: 0x23, out_of_range: 0x24, busy: 0xff }.freeze
Instance Attribute Summary collapse
-
#error_code ⇒ Symbol, ...
Parsed NACK error code as a symbolic name or raw integer.
Instance Method Summary collapse
-
#initialize(dest = nil, error_code = nil, **kwargs) ⇒ Nack
constructor
Creates a negative acknowledgement message.
-
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
-
#parse(params) ⇒ Object
Parses the negative acknowledgement error code.
Constructor Details
#initialize(dest = nil, error_code = nil, **kwargs) ⇒ Nack
Creates a negative acknowledgement message.
256 257 258 259 260 |
# File 'lib/sdn/message.rb', line 256 def initialize(dest = nil, error_code = nil, **kwargs) kwargs[:dest] ||= dest super(**kwargs) self.error_code = error_code end |
Instance Attribute Details
#error_code ⇒ Symbol, ...
Parsed NACK error code as a symbolic name or raw integer.
249 250 251 |
# File 'lib/sdn/message.rb', line 249 def error_code @error_code end |
Instance Method Details
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
272 273 274 |
# File 'lib/sdn/message.rb', line 272 def params transform_param(VALUES[error_code] || error_code) end |
#parse(params) ⇒ Object
Parses the negative acknowledgement error code.
265 266 267 268 269 |
# File 'lib/sdn/message.rb', line 265 def parse(params) super error_code = to_number(params[0]) self.error_code = VALUES.invert[error_code] || error_code end |