Class: Stormbreaker::AxeViolation

Inherits:
Object
  • Object
show all
Defined in:
lib/stormbreaker/axe_violation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(called_by: Set.new, severity: "", element: "", violation: "", complete_summary: "") ⇒ AxeViolation

Returns a new instance of AxeViolation.



7
8
9
10
11
12
13
# File 'lib/stormbreaker/axe_violation.rb', line 7

def initialize(called_by: Set.new, severity: "", element: "", violation: "", complete_summary: "")
  self.called_by = Set.new.merge(called_by)
  self.severity = severity
  self.violation = violation
  self.element = element
  self.complete_summary = complete_summary
end

Instance Attribute Details

#called_byObject

Returns the value of attribute called_by.



5
6
7
# File 'lib/stormbreaker/axe_violation.rb', line 5

def called_by
  @called_by
end

#complete_summaryObject

Returns the value of attribute complete_summary.



5
6
7
# File 'lib/stormbreaker/axe_violation.rb', line 5

def complete_summary
  @complete_summary
end

#elementObject

Returns the value of attribute element.



5
6
7
# File 'lib/stormbreaker/axe_violation.rb', line 5

def element
  @element
end

#severityObject

Returns the value of attribute severity.



5
6
7
# File 'lib/stormbreaker/axe_violation.rb', line 5

def severity
  @severity
end

#violationObject

Returns the value of attribute violation.



5
6
7
# File 'lib/stormbreaker/axe_violation.rb', line 5

def violation
  @violation
end

Instance Method Details

#==(other) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/stormbreaker/axe_violation.rb', line 21

def ==(other)
  called_by == other.called_by &&
    severity == other.severity &&
    violation == other.violation &&
    element == other.element &&
    complete_summary == other.complete_summary
end

#violation_countObject



15
16
17
18
19
# File 'lib/stormbreaker/axe_violation.rb', line 15

def violation_count
  return 0 if called_by.to_a.empty?

  called_by.to_a.map { |spec| spec.to_s.match(/(.*):/) }.uniq.count
end