class Chid::Commands::Workstation::Destroy

Public Instance Methods

run() click to toggle source
# File lib/chid/commands/workstation/destroy.rb, line 24
def run
  result = select_workstations

  if result.empty?
    puts "\nYou did not select any Workstation, please try again."
    return
  end

  chid_config.destroy_workstations(result)

  puts "\nWorkstations removed!"
end

Private Instance Methods

chid_config() click to toggle source
# File lib/chid/commands/workstation/destroy.rb, line 45
def chid_config
  ::ChidConfig.new
end
get_workstation_name() click to toggle source
# File lib/chid/commands/workstation/destroy.rb, line 39
def get_workstation_name
  puts 'tell me the name of the new workstation'
  print "> "
  STDIN.gets.strip
end
select_workstations() click to toggle source
# File lib/chid/commands/workstation/destroy.rb, line 49
def select_workstations
  prompt = TTY::Prompt.new
  workstations = chid_config.all_workstations
  choices = workstations.keys.map(&:to_s)

  prompt
    .multi_select('Select all workstations to destroy', choices)
    .map(&:to_sym)
end