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.
23 24 25 |
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 23 def initialize(parser) @parser = parser end |
Class Method Details
.parse(parser, item) ⇒ Object
16 17 18 19 20 |
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 16 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
33 34 35 36 37 38 |
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 33 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
27 28 29 30 |
# File 'lib/cosmos/packets/parsers/format_string_parser.rb', line 27 def verify_parameters @usage = "FORMAT_STRING <PRINTF STYLE STRING>" @parser.verify_num_parameters(1, 1, @usage) end |