Class: Tailor::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/tailor/formatter.rb

Overview

This is really just a base class for defining other Formatter types.

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



5
6
7
# File 'lib/tailor/formatter.rb', line 5

def initialize
  @pwd = Pathname(Dir.pwd)
end

Instance Method Details

#file_report(file_problems, label) ⇒ Object

This method gets called by Reporter after each file is critiqued. Redefine this to do what you want for that part of your report.



12
13
14
# File 'lib/tailor/formatter.rb', line 12

def file_report(file_problems, label)
  # Redefine this for your formatter...
end

#problem_levels(problems) ⇒ Array<Symbol>

Gets a list of all types of problems included in the problem set.

Parameters:

  • problems (Array)

Returns:

  • (Array<Symbol>)

    The list of problem types.



34
35
36
# File 'lib/tailor/formatter.rb', line 34

def problem_levels(problems)
  problems.values.flatten.collect { |v| v[:level] }.uniq
end

#problems_at_level(problems, level) ⇒ Array

Returns Problem list at the given level.

Parameters:

  • problems (Hash<Array>)
  • level (Symbol)

    The level of problem to find.

Returns:

  • (Array)

    Problem list at the given level.



26
27
28
# File 'lib/tailor/formatter.rb', line 26

def problems_at_level(problems, level)
  problems.values.flatten.find_all { |v| v[:level] == level }
end

#summary_report(all_problems) ⇒ Object

This method gets called by Reporter after all files are critiqued. Redefine this to do what you want for that part of your report.



19
20
21
# File 'lib/tailor/formatter.rb', line 19

def summary_report(all_problems)
  # Redefine this for your formatter...
end