Class: Bulletproof::Report
- Inherits:
-
Object
- Object
- Bulletproof::Report
- Defined in:
- lib/bulletproof/report.rb
Instance Attribute Summary collapse
-
#violations ⇒ Object
readonly
Returns the value of attribute violations.
Instance Method Summary collapse
- #add_violation(violation) ⇒ Object
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #ok? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
9 10 11 |
# File 'lib/bulletproof/report.rb', line 9 def initialize @violations = [] end |
Instance Attribute Details
#violations ⇒ Object (readonly)
Returns the value of attribute violations.
7 8 9 |
# File 'lib/bulletproof/report.rb', line 7 def violations @violations end |
Instance Method Details
#add_violation(violation) ⇒ Object
13 14 15 16 |
# File 'lib/bulletproof/report.rb', line 13 def add_violation(violation) @violations << violation self end |
#ok? ⇒ Boolean
18 19 20 |
# File 'lib/bulletproof/report.rb', line 18 def ok? @violations.empty? end |
#to_s ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bulletproof/report.rb', line 22 def to_s return "No violations found." if ok? @violations.map do |v| "[#{v.severity.upcase}] #{v.file}:#{v.line} — #{v.message}" end.join("\n") end |