Class: SSHScan::Grader

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_scan/grader.rb

Overview

A very crude means of translating # of compliance recommendations into a a grade Basic formula is 100 - (# of recommendations * 10)

Constant Summary collapse

GRADE_MAP =
{
  91..100 => "A",
  81..90 => "B",
  71..80 => "C",
  61..70 => "D",
  0..60 => "F",
}

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ Grader

Returns a new instance of Grader.



13
14
15
# File 'lib/ssh_scan/grader.rb', line 13

def initialize(result)
  @result = result
end

Instance Method Details

#gradeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ssh_scan/grader.rb', line 17

def grade
  score = 100

  if @result.compliance_recommendations.each do |recommendation|
      score -= 10
    end
  end

  GRADE_MAP.each do |score_range,grade|
    if score_range.include?(score)
      return grade
    end
  end
end