Class: GovCodes::Dafecd::RiSdi::RiListParser
- Inherits:
-
Object
- Object
- GovCodes::Dafecd::RiSdi::RiListParser
- Defined in:
- lib/gov_codes/dafecd/ri_sdi/ri_list_parser.rb
Overview
Parses a flat, numbered Reporting Identifiers (RI) list into per-code entries.
Each top-level list item (",
The title runs from the code to the FIRST of a change-date parenthetical or a sentence-ending period, and may wrap across physical lines. The officer directory omits the comma and always ends the title at the first period ("90G0 General Officer. Use this identifier ...").
Rich records carry sub-paragraphs, sometimes including a
"
Constant Summary collapse
- DECORATIVE =
Patterns::DECORATIVE
- SUBPARAGRAPH =
A sub-paragraph line ("24.1.", "56.2.1.") — where a record's body begins. Distinct from the anchor line, whose "
." is immediately followed by a code (letter in the second position), not another number-and-dot. /\A\s*\d+\.\d/- DATE_PAREN =
The title's trailing change-date parenthetical.
/\((?:Changed|Established|Effective|Change)\b/- SENTENCE_PERIOD =
A sentence-ending period: a "." followed by whitespace or end of string.
/\.(?=\s|\z)/
Instance Method Summary collapse
-
#entries ⇒ Array<Hash>
One entry per RI code, in document order.
-
#initialize(text, config: Config.dafecd) ⇒ RiListParser
constructor
A new instance of RiListParser.
Constructor Details
#initialize(text, config: Config.dafecd) ⇒ RiListParser
Returns a new instance of RiListParser.
44 45 46 47 |
# File 'lib/gov_codes/dafecd/ri_sdi/ri_list_parser.rb', line 44 def initialize(text, config: Config.dafecd) @config = config @lines = text.lines.reject { |line| line =~ config.header } end |
Instance Method Details
#entries ⇒ Array<Hash>
Returns one entry per RI code, in document order.
50 51 52 |
# File 'lib/gov_codes/dafecd/ri_sdi/ri_list_parser.rb', line 50 def entries records.filter_map { |record| parse(record) } end |