Class: Cane::ViolationFormatter

Inherits:
Struct
  • Object
show all
Defined in:
lib/cane/violation_formatter.rb

Overview

Computes a string to be displayed as output from an array of violations computed by the checks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#violationsObject

Returns the value of attribute violations

Returns:

  • (Object)

    the current value of violations



7
8
9
# File 'lib/cane/violation_formatter.rb', line 7

def violations
  @violations
end

Instance Method Details

#to_sObject



8
9
10
11
12
13
14
15
# File 'lib/cane/violation_formatter.rb', line 8

def to_s
  return '' if violations.empty?

  grouped_violations.map do |description, violations|
    format_group_header(description, violations) +
      format_violations(violations)
  end.flatten.join("\n") + "\n\n"
end