class PoParser::Parser
- PoParser::Parser
- Reference
- Object
Overview
Fast parser directly using Crystal's powerful StringScanner
Important notes about StringScanner.scan:
- Scan will return nil if there is no match. Using the regex * (zero or more) quantifier will let scan return an empty string if there is "no match" as the empty string qualifies as a match of the regex (zero times). We make use of this "trick".
- The start of line anchor ^ is obsolete as scan will only match start of line.
- Ruby's (and by extension, Crystal's) regex is in single-line mode by default, therefore scan will only match until the next newline is hit unless multi-line mode is explicitly enabled.
Defined in:
po_parser/parser.crConstructors
-
.new(message : String)
Single message parser class.
Instance Method Summary
-
#parse
Parses the message of the PO format.
Constructor Detail
def self.new(message : String)
#
Single message parser class.
@param message [String] a single PO message in String format without leading or trailing whitespace
Instance Method Detail
def parse
#
Parses the message of the PO format.
@return [Hash(Symbol, String|Hash(UInt32, String))] PO message parsed into Hash format