Class: StatModule::Finding

Inherits:
JSONable show all
Defined in:
lib/finding.rb

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

Initialize new Finding object

Params:

failure

boolean, required

rule

String, required

description

String, required

hash

Hash, can be null

Raises:



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

#categoriesObject

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

Raises:



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

#descriptionObject

Get description



69
70
71
# File 'lib/finding.rb', line 69

def description
  @description
end

#description=(description) ⇒ Object

Set description

Params:

description

String

Raises:



62
63
64
65
# File 'lib/finding.rb', line 62

def description=(description)
  raise TypeException unless description.is_a?(String)
  @description = description
end

#detailObject



83
84
85
# File 'lib/finding.rb', line 83

def detail
  @detail
end

#detail=(detail) ⇒ Object

Set detail

Params:

detail

StatModule::Detail

Raises:



78
79
80
81
# File 'lib/finding.rb', line 78

def detail=(detail)
  raise TypeException unless detail.is_a?(StatModule::Detail)
  @detail = detail
end

#failureObject

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

#fixesObject

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

Raises:



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

#locationObject

Get location



119
120
121
# File 'lib/finding.rb', line 119

def location
  @location
end

#location=(location) ⇒ Object

Set location

Params:

location

StatModule::Location

Raises:



112
113
114
115
# File 'lib/finding.rb', line 112

def location=(location)
  raise TypeException unless location.is_a?(Location)
  @location = location
end

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

#recommendationObject

Get recommendation



151
152
153
# File 'lib/finding.rb', line 151

def recommendation
  @recommendation
end

#recommendation=(recommendation) ⇒ Object

Set recommendation

Params:

recommendation

String

Raises:



144
145
146
147
# File 'lib/finding.rb', line 144

def recommendation=(recommendation)
  raise TypeException unless recommendation.is_a?(String)
  @recommendation = recommendation
end

#ruleObject

Get rule



53
54
55
# File 'lib/finding.rb', line 53

def rule
  @rule
end

#rule=(rule) ⇒ Object

Set rule

Params:

rule

String

Raises:



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_fixObject

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

Raises:



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