module ToTubePrompter

Public Instance Methods

to_tube_name(allow_none=false) click to toggle source
# File lib/pvdgm-bs-client/prompters/to_tube_prompter.rb, line 3
def to_tube_name(allow_none=false)
  return options[:to_tube] if options[:to_tube]
  return options[:to_tube] = ENV['TO_TUBE_NAME'] if ENV['TO_TUBE_NAME']
  return options[:to_tube] = prompt_for_to_tube_name(allow_none)
end

Private Instance Methods

prompt_for_to_tube_name(allow_none) click to toggle source
# File lib/pvdgm-bs-client/prompters/to_tube_prompter.rb, line 11
def prompt_for_to_tube_name(allow_none)
  result = get("beanstalk/tubes")

  # Build a menu of the tube names
  puts
  return prompter.choose do | menu |
    menu.prompt = "Select the destination beanstalk tube: "
    menu.choice("No Selection") { -1 } if allow_none
    result.each do | tube_name |
      menu.choice(tube_name) { tube_name }
    end
  end
end