Class: StatModule::Finding
Constant Summary
Constants inherited from JSONable
JSONable::FORMATTING_BALL, JSONable::FORMATTING_CHECKMARK, JSONable::FORMATTING_STAR, JSONable::FORMATTING_WARNING
Instance Method Summary collapse
-
#categories ⇒ Object
Get array of StatModule::Category objects.
-
#categories=(categories) ⇒ Object
Set array of categories.
-
#description ⇒ Object
Get description.
-
#description=(description) ⇒ Object
Set description.
- #detail ⇒ Object
-
#detail=(detail) ⇒ Object
Set detail.
-
#failure ⇒ Object
Get failure.
-
#failure=(failure) ⇒ Object
Set failure.
-
#fixes ⇒ Object
Get array of StatModule::Fix objects.
-
#fixes=(fixes) ⇒ Object
Set fixes.
-
#initialize(failure, rule, description, hash = nil) ⇒ Finding
constructor
Initialize new Finding object.
-
#location ⇒ Object
Get location.
-
#location=(location) ⇒ Object
Set location.
-
#print(formatted = false) ⇒ Object
Get formatted information about findings.
-
#recommendation ⇒ Object
Get recommendation.
-
#recommendation=(recommendation) ⇒ Object
Set recommendation.
-
#rule ⇒ Object
Get rule.
-
#rule=(rule) ⇒ Object
Set rule.
-
#time_to_fix ⇒ Object
Get time to fix.
-
#time_to_fix=(time_to_fix) ⇒ Object
Set time to fix.
Methods inherited from JSONable
Constructor Details
#initialize(failure, rule, description, hash = nil) ⇒ Finding
Initialize new Finding object
Params:
failure-
boolean, required
rule-
String, required
description-
String, required
hash-
Hash, can be null
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/finding.rb', line 14 def initialize(failure, rule, description, hash = nil) if hash.is_a? Hash super(hash) return end raise TypeException unless rule.is_a?(String) && description.is_a?(String) @failure = failure @rule = rule @description = description end |
Instance Method Details
#categories ⇒ Object
Get array of StatModule::Category objects
103 104 105 |
# File 'lib/finding.rb', line 103 def categories @categories end |
#categories=(categories) ⇒ Object
Set array of categories
Params:
categories-
array of StatModule::Category
92 93 94 95 96 97 98 99 |
# File 'lib/finding.rb', line 92 def categories=(categories) raise TypeException unless categories.is_a?(Array) categories.each { |item| raise TypeException unless Category.all.include?(item) raise DuplicateElementException if @categories.include?(item) @categories.push(item) } end |
#description ⇒ Object
Get description
69 70 71 |
# File 'lib/finding.rb', line 69 def description @description end |
#description=(description) ⇒ Object
Set description
Params:
description-
String
62 63 64 65 |
# File 'lib/finding.rb', line 62 def description=(description) raise TypeException unless description.is_a?(String) @description = description end |
#detail ⇒ Object
83 84 85 |
# File 'lib/finding.rb', line 83 def detail @detail end |
#detail=(detail) ⇒ Object
Set detail
Params:
detail-
StatModule::Detail
78 79 80 81 |
# File 'lib/finding.rb', line 78 def detail=(detail) raise TypeException unless detail.is_a?(StatModule::Detail) @detail = detail end |
#failure ⇒ Object
Get failure
37 38 39 |
# File 'lib/finding.rb', line 37 def failure @failure end |
#failure=(failure) ⇒ Object
Set failure
Params:
failure-
boolean
31 32 33 |
# File 'lib/finding.rb', line 31 def failure=(failure) @failure = failure end |
#fixes ⇒ Object
Get array of StatModule::Fix objects
171 172 173 |
# File 'lib/finding.rb', line 171 def fixes @fixes end |
#fixes=(fixes) ⇒ Object
Set fixes
Params:
fixes-
array of StatModule::Fix
160 161 162 163 164 165 166 167 |
# File 'lib/finding.rb', line 160 def fixes=(fixes) raise TypeException unless fixes.is_a?(Array) fixes.each { |item| raise TypeException unless item.is_a?(StatModule::Fix) raise DuplicateElementException if @fixes.include?(item) @fixes.push(item) } end |
#location ⇒ Object
Get location
119 120 121 |
# File 'lib/finding.rb', line 119 def location @location end |
#location=(location) ⇒ Object
Set location
Params:
location-
StatModule::Location
112 113 114 115 |
# File 'lib/finding.rb', line 112 def location=(location) raise TypeException unless location.is_a?(Location) @location = location end |
#print(formatted = false) ⇒ Object
Get formatted information about findings
Params:
formatted-
indicate weather print boring or pretty colorful finding
181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/finding.rb', line 181 def print(formatted = false) result = "#{rule}, #{description}" if formatted if failure result = "#{FORMATTING_BALL} #{result}".colorize(:red) else result = "#{FORMATTING_WARNING} #{result}".colorize(:yellow) end end result += "\n#{location.print}" unless location.nil? result += "\nRECOMMENDATION: #{recommendation}" unless recommendation.nil? result end |
#recommendation ⇒ Object
Get recommendation
151 152 153 |
# File 'lib/finding.rb', line 151 def recommendation @recommendation end |
#recommendation=(recommendation) ⇒ Object
Set recommendation
Params:
recommendation-
String
144 145 146 147 |
# File 'lib/finding.rb', line 144 def recommendation=(recommendation) raise TypeException unless recommendation.is_a?(String) @recommendation = recommendation end |
#rule ⇒ Object
Get rule
53 54 55 |
# File 'lib/finding.rb', line 53 def rule @rule end |
#rule=(rule) ⇒ Object
Set rule
Params:
rule-
String
46 47 48 49 |
# File 'lib/finding.rb', line 46 def rule=(rule) raise TypeException unless rule.is_a?(String) @rule = rule end |
#time_to_fix ⇒ Object
Get time to fix
135 136 137 |
# File 'lib/finding.rb', line 135 def time_to_fix @timeToFix end |
#time_to_fix=(time_to_fix) ⇒ Object
Set time to fix
Params:
time_to_fix-
Integer
128 129 130 131 |
# File 'lib/finding.rb', line 128 def time_to_fix=(time_to_fix) raise TypeException unless time_to_fix.is_a?(Integer) @timeToFix = time_to_fix end |