Class: Cosmos::FormatStringParser
- Defined in:
- lib/cosmos/packets/parsers/format_string_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_format_string(item) ⇒ Object
-
#initialize(parser) ⇒ FormatStringParser
constructor
A new instance of FormatStringParser.
- #verify_parameters ⇒ Object
Constructor Details
#initialize(parser) ⇒ FormatStringParser
Returns a new instance of FormatStringParser.
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
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
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_parameters ⇒ Object
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 |