Class: OpenC3::FormatStringParser

Inherits:
Object
  • Object
show all
Defined in:
lib/openc3/packets/parsers/format_string_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ FormatStringParser

Returns a new instance of FormatStringParser.

Parameters:



34
35
36
# File 'lib/openc3/packets/parsers/format_string_parser.rb', line 34

def initialize(parser)
  @parser = parser
end

Class Method Details

.parse(parser, item) ⇒ Object

Parameters:



27
28
29
30
31
# File 'lib/openc3/packets/parsers/format_string_parser.rb', line 27

def self.parse(parser, item)
  parser = FormatStringParser.new(parser)
  parser.verify_parameters()
  parser.create_format_string(item)
end

Instance Method Details

#create_format_string(item) ⇒ Object

Parameters:

  • item (PacketItem)

    The item the limits response should be added to



44
45
46
47
48
49
# File 'lib/openc3/packets/parsers/format_string_parser.rb', line 44

def create_format_string(item)
  item.format_string = @parser.parameters[0]
  # Only test the format string if there is not a read conversion because
  # read conversion can return any type
  test_format_string(item) unless item.read_conversion
end

#verify_parametersObject



38
39
40
41
# File 'lib/openc3/packets/parsers/format_string_parser.rb', line 38

def verify_parameters
  @usage = "FORMAT_STRING <PRINTF STYLE STRING>"
  @parser.verify_num_parameters(1, 1, @usage)
end