Class: Mpx::Command

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

Overview

Represents a command to be run.

Instance Method Summary collapse

Constructor Details

#initialize(bin, working_directory) ⇒ Command

Returns a new instance of Command.



10
11
12
13
# File 'lib/mpx/command.rb', line 10

def initialize(bin, working_directory)
  @bin = bin
  @working_directory = working_directory
end

Instance Method Details

#<=>(other) ⇒ Object



15
16
17
# File 'lib/mpx/command.rb', line 15

def <=>(other)
  return self.name <=> other.name
end

#nameObject



19
20
21
# File 'lib/mpx/command.rb', line 19

def name
  return File.basename(@bin)
end

#run(args) ⇒ Object



23
24
25
26
# File 'lib/mpx/command.rb', line 23

def run(args)
  opened = Open3.capture2e(@bin, *args, :chdir => @working_directory)
  return Result.new(name, *opened)
end