Class: Reviewer::Guidance

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/guidance.rb

Overview

Handles the logic around what to display after a command has been run

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command:, result:, output: Reviewer.output) ⇒ Guidance

Create an instance of guidance for suggesting recovery steps after errors

Parameters:

  • command: (Command)

    the command that was run and needs recovery guidance

  • result: (Result)

    the result of the command

  • output: (defaults to: Reviewer.output)

    Reviewer.output [Output] the output channel for displaying content



16
17
18
19
20
# File 'lib/reviewer/guidance.rb', line 16

def initialize(command:, result:, output: Reviewer.output)
  @command = command
  @result = result
  @output = output
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



8
9
10
# File 'lib/reviewer/guidance.rb', line 8

def command
  @command
end

#outputObject (readonly)

Returns the value of attribute output.



8
9
10
# File 'lib/reviewer/guidance.rb', line 8

def output
  @output
end

#resultObject (readonly)

Returns the value of attribute result.



8
9
10
# File 'lib/reviewer/guidance.rb', line 8

def result
  @result
end

Instance Method Details

#showvoid

This method returns an undefined value.

Prints the relevant guidance based on the command and result context



25
26
27
28
29
30
31
# File 'lib/reviewer/guidance.rb', line 25

def show
  case result
  when executable_not_found? then show_missing_executable_guidance
  when cannot_execute?       then show_unrecoverable_guidance
  else                            show_syntax_guidance
  end
end