Sha256: f021dd3ff81ef00e916f656a72d276b77d2d789e84bde51d951152b51399724b
Contents?: true
Size: 807 Bytes
Versions: 2
Compression:
Stored size: 807 Bytes
Contents
module LensProtocol module OMA class Parser def parse oma_str, types: {} types = TYPES.merge(types) lines = convert_to_structured_lines normalize_line_endings(oma_str).split("\n") parse_lines lines, types, Message.new end private def normalize_line_endings str str.to_s.gsub /\r\n?/, "\n" end def convert_to_structured_lines lines lines.map { |line| Line.parse line } end def parse_lines lines, types, message line, *next_lines = lines if line value, next_lines = types[line.label].parse(line, next_lines) message.add_record(line.label, value) if value parse_lines next_lines, types, message else message end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lens_protocol-0.2.1 | lib/lens_protocol/oma/parser.rb |
lens_protocol-0.2.0 | lib/lens_protocol/oma/parser.rb |