Class: NMEAPlus::NMEAMessageFactory

Inherits:
MessageFactory show all
Defined in:
lib/nmea_plus/nmea_message_factory.rb

Overview

Defines a factory for NMEA messages, which will all use Message::NMEA::NMEAMessage as their base. The factory extracts the NMEA data type (prefixed by a 2-character “talker ID”), and looks for a class with that name within the NMEA message namespace.

Class Method Summary collapse

Methods inherited from MessageFactory

best_match_for_data_type, create, dynamically_get_message_object, message_class_exists?, message_class_name

Class Method Details

.alternate_data_type(data_type) ⇒ Array

Match all NMEA messages as their generic counterparts. GPGLL becomes GLL, etc.

Parameters:

  • data_type (String)

    The data_type of the NMEA message (e.g. the GPGLL of “$GPGLL,12,3,,4,5*00”)

Returns:

  • (Array)

    Array of data_type strings that we will attempt to use in decoding the message



186
187
188
189
190
191
192
193
194
# File 'lib/nmea_plus/nmea_message_factory.rb', line 186

def self.alternate_data_type(data_type)
  # match last 3 digits (get rid of talker)
  sentence_type = data_type[2..4]
  alternates = [sentence_type]

  # Match special Route messages: R00 is the same as R01, R02...
  alternates.push('R00') unless /R\d\d/.match(sentence_type).nil?
  alternates
end

.parent_moduleString

Returns The name of the parent module: NMEA.

Returns:

  • (String)

    The name of the parent module: NMEA



179
180
181
# File 'lib/nmea_plus/nmea_message_factory.rb', line 179

def self.parent_module
  'NMEA'
end