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
Methods inherited from JSONable
from_json!, #to_json
Constructor Details
#initialize(failure, rule, description, hash = nil) ⇒ Finding
Returns a new instance of Finding.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/finding.rb', line 6
def initialize(failure, rule, description, hash = nil)
@categories = []
@fixes = []
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
65
66
67
|
# File 'lib/finding.rb', line 65
def categories
@categories
end
|
#categories=(categories) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/finding.rb', line 56
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
43
44
45
|
# File 'lib/finding.rb', line 43
def description
@description
end
|
#description=(description) ⇒ Object
38
39
40
41
|
# File 'lib/finding.rb', line 38
def description=(description)
raise TypeException unless description.is_a?(String)
@description = description
end
|
#detail ⇒ Object
52
53
54
|
# File 'lib/finding.rb', line 52
def detail
@detail
end
|
#detail=(detail) ⇒ Object
47
48
49
50
|
# File 'lib/finding.rb', line 47
def detail=(detail)
raise TypeException unless detail.is_a?(StatModule::Detail)
@detail = detail
end
|
#failure ⇒ Object
25
26
27
|
# File 'lib/finding.rb', line 25
def failure
@failure
end
|
#failure=(failure) ⇒ Object
21
22
23
|
# File 'lib/finding.rb', line 21
def failure=(failure)
@failure = failure
end
|
#fixes ⇒ Object
105
106
107
|
# File 'lib/finding.rb', line 105
def fixes
@fixes
end
|
#fixes=(fixes) ⇒ Object
96
97
98
99
100
101
102
103
|
# File 'lib/finding.rb', line 96
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
74
75
76
|
# File 'lib/finding.rb', line 74
def location
@location
end
|
#location=(location) ⇒ Object
69
70
71
72
|
# File 'lib/finding.rb', line 69
def location=(location)
raise TypeException unless location.is_a?(Location)
@location = location
end
|
#print(formatted = false) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/finding.rb', line 109
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
92
93
94
|
# File 'lib/finding.rb', line 92
def recommendation
@recommendation
end
|
#recommendation=(recommendation) ⇒ Object
87
88
89
90
|
# File 'lib/finding.rb', line 87
def recommendation=(recommendation)
raise TypeException unless recommendation.is_a?(String)
@recommendation = recommendation
end
|
#rule ⇒ Object
34
35
36
|
# File 'lib/finding.rb', line 34
def rule
@rule
end
|
#rule=(rule) ⇒ Object
29
30
31
32
|
# File 'lib/finding.rb', line 29
def rule=(rule)
raise TypeException unless rule.is_a?(String)
@rule = rule
end
|
#time_to_fix ⇒ Object
83
84
85
|
# File 'lib/finding.rb', line 83
def time_to_fix
@timeToFix
end
|
#time_to_fix=(time_to_fix) ⇒ Object
78
79
80
81
|
# File 'lib/finding.rb', line 78
def time_to_fix=(time_to_fix)
raise TypeException unless time_to_fix.is_a?(Integer)
@timeToFix = time_to_fix
end
|