Module: Pio::MessageTypeSelector

Included in:
Arp, Echo, Features, Icmp
Defined in:
lib/pio/message_type_selector.rb

Overview

Macros for defining message types.

Instance Method Summary collapse

Instance Method Details

#message_type(options) ⇒ Object



8
9
10
# File 'lib/pio/message_type_selector.rb', line 8

def message_type(options)
  const_set(:MESSAGE_TYPE, options)
end

#read(raw_data) ⇒ Object



12
13
14
15
16
17
# File 'lib/pio/message_type_selector.rb', line 12

def read(raw_data)
  parsed = const_get(:Format).read(raw_data)
  const_get(:MESSAGE_TYPE)[parsed.message_type].create_from parsed
rescue
  raise Pio::ParseError, $ERROR_INFO.message
end