Module: EISCP::Parser::EISCPParser
- Defined in:
- lib/eiscp/parser/eiscp_parser.rb
Overview
This module parses an eISCP string and returns a Message object
Class Method Summary collapse
Class Method Details
.parse(string) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eiscp/parser/eiscp_parser.rb', line 8 def self.parse(string) array = string.unpack('A4NNCa3A*') msg = ISCPParser.parse(array[5]) packet = Message.new( command: msg.command, value: msg.value, terminator: msg.terminator, unit_type: msg.unit_type, start: msg.start ) packet.header = { magic: array[0], header_size: array[1], data_size: array[2], version: array[3], reserved: array[4] } packet end |
.validate(packet) ⇒ Object
28 29 30 |
# File 'lib/eiscp/parser/eiscp_parser.rb', line 28 def self.validate(packet) packet.header.header_size.size == packet.command.size end |