class Dramaturg::Prompter::Base

Attributes

script[R]

Public Class Methods

new(script,config) click to toggle source
# File lib/dramaturg/prompter/base.rb, line 6
def initialize(script,config)
  @script = script
  @prompt = config[:prompt]
  @formatters = config[:format]

  @current_command = nil
end

Public Instance Methods

abort!() click to toggle source
# File lib/dramaturg/prompter/base.rb, line 24
def abort!
  @current_command.skip
  return false
end
call(cmd) click to toggle source
# File lib/dramaturg/prompter/base.rb, line 14
def call(cmd)
  @current_command = cmd
  value_map = prepare_values(cmd)
  display = format_for_display(value_map)

  results = doIO(display, value_map)

  process_results(results, value_map)
end

Private Instance Methods

prepare_values(cmd, debug=false) click to toggle source
# File lib/dramaturg/prompter/base.rb, line 38
def prepare_values(cmd, debug=false)
  cmd.map do |v|
    str = debug ? v.for_debug_prompt : v.for_prompt
    [v, tr_method_map[v].(str)]
  end.to_h
end
prompt_for_display() click to toggle source
# File lib/dramaturg/prompter/base.rb, line 30
def prompt_for_display
  if @prompt.respond_to? :call
    @prompt.(self)
  else
    @prompt
  end
end