Class: Executor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Executor

Returns a new instance of Executor.



6
7
8
# File 'lib/executor.rb', line 6

def initialize(command)
	@command = command
end

Instance Attribute Details

#exit_codeObject (readonly)

Returns the value of attribute exit_code.



4
5
6
# File 'lib/executor.rb', line 4

def exit_code
  @exit_code
end

#outputObject (readonly)

Returns the value of attribute output.



4
5
6
# File 'lib/executor.rb', line 4

def output
  @output
end

Instance Method Details

#executeObject



10
11
12
13
14
15
# File 'lib/executor.rb', line 10

def execute
	@output, status = Open3.capture2e(@command)
	@exit_code = status.exitstatus

	success?
end

#success?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/executor.rb', line 17

def success?
	@exit_code.nil? ? true : @exit_code.zero?
end