Class: RuboCounsel::CopActions::ShowExamples

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocounsel/cop_actions.rb

Overview

Displays all examples for a cop, then signals re-prompt.

Instance Method Summary collapse

Constructor Details

#initialize(examples, output: $stdout) ⇒ ShowExamples

Returns a new instance of ShowExamples.



25
26
27
28
# File 'lib/rubocounsel/cop_actions.rb', line 25

def initialize(examples, output: $stdout)
  @examples = examples
  @output = output
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
# File 'lib/rubocounsel/cop_actions.rb', line 33

def call
  @examples.each do |example|
    example_label = example.default? ? "#{example.value} (default)" : example.value
    @output.puts "      \#{::CLI::UI.fmt(\"{{yellow:\#{example_label}:}}\")}\n      \#{example.text}\n    OUTPUT\n  end\nend\n"

#labelObject



30
# File 'lib/rubocounsel/cop_actions.rb', line 30

def label = "Show examples"

#reprompt?Boolean

Returns:

  • (Boolean)


31
# File 'lib/rubocounsel/cop_actions.rb', line 31

def reprompt? = true