class

PoParser::Parser

Inherits Reference < Object

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.

Constructors

new(message : String)

Single message parser class.

@param message [String] a single PO message in String format without leading or trailing whitespace

Source

Instance methods

parse

Parses the message of the PO format.

@return [Message]

Source