Class: RiskRecord
- Inherits:
-
Decision
- Object
- BaseDocument
- PersistentDocument
- Decision
- RiskRecord
- Defined in:
- lib/almirah/doc_types/risk_record.rb
Overview
A risk record (ADR-215): one Markdown file per risk, collected from the first-level subfolders of the project's risks/ folder, each subfolder being a risk registry. The record format is the decision-record format — filename letters-digits id, frontmatter title, Status table with a "*" current-state marker — so the type reuses Decision wholesale.
Instance Attribute Summary collapse
-
#registry ⇒ Object
The first-level risks/ subfolder the record was collected from.
Attributes inherited from Decision
#current_status, #html_rel_path, #owners, #path, #record_type, #root_prefix, #scope_table, #sequence_number, #specifications_path, #start_date, #target_date, #target_release_version, #wrong_links_hash
Attributes inherited from PersistentDocument
#controlled_items, #frontmatter, #headings, #items, #path, #up_link_docs
Attributes inherited from BaseDocument
#dom, #headings, #id, #output_rel_path, #title
Instance Method Summary collapse
-
#affected_document_ids ⇒ Object
The distinct controlled-paragraph IDs the record's Affected Documents Req-ID column links to (ADR-218), in the section's row order — the IDs-only content of the register cell.
-
#rpn_value(group) ⇒ Object
The record's value for an RPN group (ADR-217): the product of its numeric input sections.
-
#section_html(section_name) ⇒ Object
The rendered HTML of the record section whose heading text equals
section_name(ADR-216). -
#section_numeric(section_name) ⇒ Object
The numeric value of the named section (ADR-217): its items' plain text parsed as a Float.
- #to_console ⇒ Object
Methods inherited from Decision
#actual_hours, #actual_hours_on, #declared_dependencies?, #effective_status_on, #effort_date_range, #extract_current_status, #extract_owners, #extract_scope_table, #extract_start_date, #extract_target_date, #extract_target_release_version, #fully_kitted?, #in_progress_owner_tally, #initialize, #kit_started_violation?, #row_actual_hours_on, #scope_work_items, #to_html
Methods inherited from PersistentDocument
Methods inherited from BaseDocument
#critical_chain_link, #decisions_link, #home_link, #index_link, #initialize, #needs_chartjs?, #rel_to, #risks_link, #save_html_to_file
Constructor Details
This class inherits a constructor from Decision
Instance Attribute Details
#registry ⇒ Object
The first-level risks/ subfolder the record was collected from.
13 14 15 |
# File 'lib/almirah/doc_types/risk_record.rb', line 13 def registry @registry end |
Instance Method Details
#affected_document_ids ⇒ Object
The distinct controlled-paragraph IDs the record's Affected Documents Req-ID column links to (ADR-218), in the section's row order — the IDs-only content of the register cell. Empty when the record carries no Affected Documents section or its rows link nothing.
48 49 50 51 52 53 |
# File 'lib/almirah/doc_types/risk_record.rb', line 48 def affected_document_ids table = section_items('Affected Documents').find { |i| i.is_a?(ControlledTable) } return [] if table.nil? table.rows.flat_map { |row| row.up_link_ids || [] }.uniq end |
#rpn_value(group) ⇒ Object
The record's value for an RPN group (ADR-217): the product of its numeric input sections. nil when any input is missing or not numeric — such a record renders a blank cell and is ignored by the summary aggregates.
37 38 39 40 41 42 |
# File 'lib/almirah/doc_types/risk_record.rb', line 37 def rpn_value(group) factors = group[:inputs].map { |input| section_numeric(input) } return nil if factors.any?(&:nil?) factors.reduce(:*) end |
#section_html(section_name) ⇒ Object
The rendered HTML of the record section whose heading text equals
section_name (ADR-216). Empty when there is no such section — the
register renders it as an empty cell.
22 23 24 |
# File 'lib/almirah/doc_types/risk_record.rb', line 22 def section_html(section_name) section_items(section_name).map(&:to_html).join end |
#section_numeric(section_name) ⇒ Object
The numeric value of the named section (ADR-217): its items' plain text parsed as a Float. nil when the section is missing, empty, or not numeric — the RPN cell renders blank rather than computing a broken record as safe.
29 30 31 32 |
# File 'lib/almirah/doc_types/risk_record.rb', line 29 def section_numeric(section_name) texts = section_items(section_name).filter_map { |i| i.text if i.respond_to?(:text) } Float(texts.join(' ').strip, exception: false) end |
#to_console ⇒ Object
15 16 17 |
# File 'lib/almirah/doc_types/risk_record.rb', line 15 def to_console puts "\e[36mRisk Record: #{@id}\e[0m" end |