Class: GovCodes::Dafecd::RiSdi::RiListParser

Inherits:
Object
  • Object
show all
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 (". , . <date>") is one record, delimited by the next top-level number. The anchor tolerates the source's pdf-reader glue and decoration: an optional run of spaces (or none) after "<n>.", an optional leading decorative star, a comma OR a bare space before the title, and a list number glued to the code ("34.9T000").</p> <p>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 ...").</p> <p>Rich records carry sub-paragraphs, sometimes including a "<n>.x Specialty Shredouts:" table, which is parsed by the reused ShredoutParser. Records are returned in document order; #entries also carries each item's :number so callers can run the 1..N completeness check.</p> </div> </div> <div class="tags"> </div> <h2> Constant Summary <small><a href="#" class="constants_summary_toggle">collapse</a></small> </h2> <dl class="constants"> <dt id="DECORATIVE-constant" class="">DECORATIVE = </dt> <dd><pre class="code"><span class='const'><span class='object_link'><a href="../Patterns.html" title="GovCodes::Dafecd::Patterns (module)">Patterns</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Patterns.html#DECORATIVE-constant" title="GovCodes::Dafecd::Patterns::DECORATIVE (constant)">DECORATIVE</a></span></span></pre></dd> <dt id="SUBPARAGRAPH-constant" class="">SUBPARAGRAPH = <div class="docstring"> <div class="discussion"> <p>A sub-paragraph line ("24.1.", "56.2.1.") — where a record's body begins. Distinct from the anchor line, whose "<n>." is immediately followed by a code (letter in the second position), not another number-and-dot.</p> </div> </div> <div class="tags"> </div> </dt> <dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A\s*\d+\.\d</span><span class='regexp_end'>/</span></span></pre></dd> <dt id="DATE_PAREN-constant" class="">DATE_PAREN = <div class="docstring"> <div class="discussion"> <p>The title's trailing change-date parenthetical.</p> </div> </div> <div class="tags"> </div> </dt> <dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\((?:Changed|Established|Effective|Change)\b</span><span class='regexp_end'>/</span></span></pre></dd> <dt id="SENTENCE_PERIOD-constant" class="">SENTENCE_PERIOD = <div class="docstring"> <div class="discussion"> <p>A sentence-ending period: a "." followed by whitespace or end of string.</p> </div> </div> <div class="tags"> </div> </dt> <dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.(?=\s|\z)</span><span class='regexp_end'>/</span></span></pre></dd> </dl> <h2> Instance Method Summary <small><a href="#" class="summary_toggle">collapse</a></small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#entries-instance_method" title="#entries (instance method)">#<strong>entries</strong> ⇒ Array<Hash> </a> </span> <span class="summary_desc"><div class='inline'><p>One entry per RI code, in document order.</p></div></span> </li> <li class="public "> <span class="summary_signature"> <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(text, config: Config.dafecd) ⇒ RiListParser </a> </span> <span class="note title constructor">constructor</span> <span class="summary_desc"><div class='inline'><p>A new instance of RiListParser.</p></div></span> </li> </ul> <div id="constructor_details" class="method_details_list"> <h2>Constructor Details</h2> <div class="method_details first"> <h3 class="signature first" id="initialize-instance_method"> #<strong>initialize</strong>(text, config: Config.dafecd) ⇒ <tt><span class='object_link'><a href="" title="GovCodes::Dafecd::RiSdi::RiListParser (class)">RiListParser</a></span></tt> </h3><div class="docstring"> <div class="discussion"> <p>Returns a new instance of RiListParser.</p> </div> </div> <div class="tags"> </div><table class="source_code"> <tr> <td> <pre class="lines"> 44 45 46 47</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/gov_codes/dafecd/ri_sdi/ri_list_parser.rb', line 44</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_text'>text</span><span class='comma'>,</span> <span class='label'>config:</span> <span class='const'><span class='object_link'><a href="Config.html" title="GovCodes::Dafecd::RiSdi::Config (class)">Config</a></span></span><span class='period'>.</span><span class='id identifier rubyid_dafecd'><span class='object_link'><a href="Config.html#dafecd-class_method" title="GovCodes::Dafecd::RiSdi::Config.dafecd (method)">dafecd</a></span></span><span class='rparen'>)</span> <span class='ivar'>@config</span> <span class='op'>=</span> <span class='id identifier rubyid_config'>config</span> <span class='ivar'>@lines</span> <span class='op'>=</span> <span class='id identifier rubyid_text'>text</span><span class='period'>.</span><span class='id identifier rubyid_lines'>lines</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span> <span class='id identifier rubyid_line'>line</span> <span class='op'>=~</span> <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_header'>header</span> <span class='rbrace'>}</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> </div> <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> <h3 class="signature first" id="entries-instance_method"> #<strong>entries</strong> ⇒ <tt>Array<Hash></tt> </h3><div class="docstring"> <div class="discussion"> <p>Returns one entry per RI code, in document order.</p> </div> </div> <div class="tags"> <p class="tag_title">Returns:</p> <ul class="return"> <li> <span class='type'>(<tt>Array<Hash></tt>)</span> — <div class='inline'><p>one entry per RI code, in document order</p></div> </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 50 51 52</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/gov_codes/dafecd/ri_sdi/ri_list_parser.rb', line 50</span> <span class='kw'>def</span> <span class='id identifier rubyid_entries'>entries</span> <span class='id identifier rubyid_records'>records</span><span class='period'>.</span><span class='id identifier rubyid_filter_map'>filter_map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='op'>|</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> </div> </div> <div id="footer"> Generated on Thu Jul 16 14:26:25 2026 by <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.44 (ruby-4.0.2). </div> </div> </body> </html>