class KafoWizards::HighLine::Wizard

Public Instance Methods

execute_menu() click to toggle source
# File lib/kafo_wizards/highline/wizard.rb, line 7
def execute_menu
  begin
    choice = nil
    loop do
      say "\n"
      say ::HighLine.color(header, :yellow) unless header.empty?
      print_values
      say "\n" + description
      choice = print_menu
      break unless choice.nil?
    end
    validate(values) if triggers.include? choice
    choice
  rescue KafoWizards::ValidationError => e
    say ::HighLine.color("\nUnable to procedd due to following error(s):", :red)
    say ::HighLine.color(format_errors(e.messages), :red)
    say "\n"
    retry
  end
end
print_menu() click to toggle source
print_values() click to toggle source
render_action(entry) click to toggle source
# File lib/kafo_wizards/highline/wizard.rb, line 67
def render_action(entry)
  call_renderer_for_entry(:render_action, entry)
end
render_entry(entry) click to toggle source
# File lib/kafo_wizards/highline/wizard.rb, line 75
def render_entry(entry)
  call_renderer_for_entry(:render_entry, entry)
end
render_value(entry) click to toggle source
# File lib/kafo_wizards/highline/wizard.rb, line 71
def render_value(entry)
  call_renderer_for_entry(:render_value, entry)
end

Protected Instance Methods

format_errors(errors) click to toggle source
# File lib/kafo_wizards/highline/wizard.rb, line 94
def format_errors(errors)
  errors.map{ |e| "- #{e}"}.join("\n")
end
sorted_entries() click to toggle source
# File lib/kafo_wizards/highline/wizard.rb, line 80
def sorted_entries
  sorted = { :default => [], :entries => [], :buttons => []}
  sorted = entries.inject(sorted) do |res, entry|
    if entry.class <= KafoWizards::Entries::ButtonEntry
      cat = entry.default? ? :default : :buttons
    else
      cat = :entries
    end
    res[cat] << entry
    res
  end
  sorted[:default] + sorted[:entries] + sorted[:buttons]
end