Class: Mago::Cli::Formatter

Inherits:
Object
  • Object
show all
Includes:
Colorize
Defined in:
lib/mago/cli/formatter.rb

Overview

Formats report to be printed

Direct Known Subclasses

SourceFormatter

Instance Method Summary collapse

Methods included from Colorize

#colorize, #green, #pink, #red, #yellow

Constructor Details

#initialize(report, opts = {}) ⇒ Formatter

Returns a new instance of Formatter.

Parameters:

Options Hash (opts):

  • :color (Boolean)

    whether colorize output or no



11
12
13
14
# File 'lib/mago/cli/formatter.rb', line 11

def initialize(report, opts = {})
  @report = report
  @color  = opts[:color]
end

Instance Method Details

#formatString

Format report.

Returns:

  • (String)

    formated report



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/mago/cli/formatter.rb', line 19

def format
  out = ''

  @report.files.each do |file|
    format_file(file, out)
  end

  @report.errors.each do |error|
    format_error(error, out)
  end

  out
end