class Chid::Commands::Workstation::Open
Public Instance Methods
run()
click to toggle source
# File lib/chid/commands/workstation/open.rb, line 34 def run workstation_name = workstation_name_from_options workstation_name = select_workstation if workstation_name.empty? open_apps(workstation_name) end
Private Instance Methods
chid_config()
click to toggle source
# File lib/chid/commands/workstation/open.rb, line 58 def chid_config ::ChidConfig.new end
open_apps(workstation_name)
click to toggle source
# File lib/chid/commands/workstation/open.rb, line 73 def open_apps(workstation_name) puts "\nOpening all Apps" apps = workstations[workstation_name.to_sym] apps.each do |app_name| ::ChidConfig.on_osx do system("open -a #{app_name}") end ::ChidConfig.on_linux do system("#{app_name} >/dev/null 2>&1 &") end end end
select_workstation()
click to toggle source
# File lib/chid/commands/workstation/open.rb, line 66 def select_workstation prompt = TTY::Prompt.new choices = workstations.keys.map(&:to_s) selected_workstation = prompt.select('Choose a workstation to open', choices) selected_workstation end
workstation_name_from_options()
click to toggle source
Returns the workstation name mapped from the values of the options attribute. Will remove all nil values and join the array of values into String
@return [String] Mapped values from options attribute
If the options does not exist, will return empty String #=> ""
@example Workstation
Name
options = {'-name' => ['base', 'two']} workstation_name #=> 'base two'
# File lib/chid/commands/workstation/open.rb, line 54 def workstation_name_from_options @workstation_name ||= self.class.arguments.map { |a| options[a] }.compact.join(' ') end
workstations()
click to toggle source
# File lib/chid/commands/workstation/open.rb, line 62 def workstations @workstations ||= chid_config.all_workstations end