Class: RuboCounsel::CopActions::ShowExamples
- Inherits:
-
Object
- Object
- RuboCounsel::CopActions::ShowExamples
- Defined in:
- lib/rubocounsel/cop_actions.rb
Overview
Displays all examples for a cop, then signals re-prompt.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(examples, output: $stdout) ⇒ ShowExamples
constructor
A new instance of ShowExamples.
- #label ⇒ Object
- #reprompt? ⇒ Boolean
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
#call ⇒ Object
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" |
#label ⇒ Object
30 |
# File 'lib/rubocounsel/cop_actions.rb', line 30 def label = "Show examples" |
#reprompt? ⇒ Boolean
31 |
# File 'lib/rubocounsel/cop_actions.rb', line 31 def reprompt? = true |