Class: AppleSimUtils::Cmd

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_sim_utils/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCmd

Returns a new instance of Cmd.



5
6
7
# File 'lib/apple_sim_utils/command.rb', line 5

def initialize
  @path = get_command_path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/apple_sim_utils/command.rb', line 3

def path
  @path
end

Instance Method Details

#run(*command) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/apple_sim_utils/command.rb', line 9

def run(*command)
  cmd = ([@path] + command).join(' ')
  sto, ste, status = Open3.capture3(cmd)
  if status.success?
    unless ste.empty?
      puts ste
      return ste
    end
    sto
  else
    puts ste
    raise(sto)
  end
end