Class: Cosmos::FormatStringParser

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/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:



31
32
33
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 31

def initialize(parser)
  @parser = parser
end

Class Method Details

.parse(parser, item) ⇒ Object

Parameters:



24
25
26
27
28
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 24

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



41
42
43
44
45
46
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 41

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



35
36
37
38
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 35

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