Module: RpnRendering

Included in:
RiskRegistryPage, RisksOverview
Defined in:
lib/almirah/doc_types/rpn_rendering.rb

Overview

Shared RPN cell presentation (ADR-217, reused by the registries summary of ADR-219): the threshold band class and the integer-when-whole formatting.

Instance Method Summary collapse

Instance Method Details

#format_rpn(value) ⇒ Object

Whole values print as integers (8 * 3 -> 24, not 24.0).



20
21
22
# File 'lib/almirah/doc_types/rpn_rendering.rb', line 20

def format_rpn(value)
  value == value.to_i ? value.to_i.to_s : value.to_s
end

#rpn_threshold_class(value, group) ⇒ Object

Acceptable at or below the acceptable bound, unacceptable at or above the unacceptable bound, caution between them (the ALARP band); a lone bound leaves the rest of the range as caution. nil when no thresholds configured.



9
10
11
12
13
14
15
16
17
# File 'lib/almirah/doc_types/rpn_rendering.rb', line 9

def rpn_threshold_class(value, group)
  if group[:acceptable] && value <= group[:acceptable]
    'rpn_acceptable'
  elsif group[:unacceptable] && value >= group[:unacceptable]
    'rpn_unacceptable'
  elsif group[:acceptable] || group[:unacceptable]
    'rpn_caution'
  end
end