Module: CvssSuite::Cvss31Helper

Defined in:
lib/cvss_suite/helpers/cvss31_helper.rb

Overview

This module includes methods which are used by the CVSS 3 classes.

Class Method Summary collapse

Class Method Details

.round_up(float) ⇒ Object

Since CVSS 3 all float values are rounded up, therefore this method is used instead of the mathematically correct method round().



19
20
21
22
23
24
25
26
# File 'lib/cvss_suite/helpers/cvss31_helper.rb', line 19

def self.round_up(float)
  output = (float * 100_000).round
  if (output % 10_000).zero?
    output / 100_000.0
  else
    ((output / 10_000).floor + 1) / 10.0
  end
end