Class: I18nFlow::CLI::LintCommand::AsciiRenderer
- Inherits:
-
Object
- Object
- I18nFlow::CLI::LintCommand::AsciiRenderer
- Includes:
- Color
- Defined in:
- lib/i18n_flow/cli/lint_command/ascii_renderer.rb
Constant Summary collapse
- FILE =
__dir__ + '/ascii.erb'
Constants included from Color
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #color_enabled? ⇒ Boolean
- #error_count ⇒ Object
- #file_count ⇒ Object
-
#initialize(errors, color: true) ⇒ AsciiRenderer
constructor
A new instance of AsciiRenderer.
- #render ⇒ Object
- #summary_line ⇒ Object
Methods included from Color
Constructor Details
#initialize(errors, color: true) ⇒ AsciiRenderer
Returns a new instance of AsciiRenderer.
13 14 15 16 |
# File 'lib/i18n_flow/cli/lint_command/ascii_renderer.rb', line 13 def initialize(errors, color: true) @errors = errors @color_enabled = !!color end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/i18n_flow/cli/lint_command/ascii_renderer.rb', line 11 def errors @errors end |
Instance Method Details
#color_enabled? ⇒ Boolean
22 23 24 |
# File 'lib/i18n_flow/cli/lint_command/ascii_renderer.rb', line 22 def color_enabled? @color_enabled end |
#error_count ⇒ Object
30 31 32 |
# File 'lib/i18n_flow/cli/lint_command/ascii_renderer.rb', line 30 def error_count @error_count ||= errors.sum { |_, errs| errs.size } end |
#file_count ⇒ Object
26 27 28 |
# File 'lib/i18n_flow/cli/lint_command/ascii_renderer.rb', line 26 def file_count @file_count ||= errors.size end |
#render ⇒ Object
18 19 20 |
# File 'lib/i18n_flow/cli/lint_command/ascii_renderer.rb', line 18 def render with_color(erb.result(binding)) end |
#summary_line ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/i18n_flow/cli/lint_command/ascii_renderer.rb', line 34 def summary_line @summary_line ||= 'Found %d %s in %d %s' % [ error_count, error_count == 1 ? 'violation' : 'violations', file_count, file_count == 1 ? 'file' : 'files', ] end |