Class: Executor

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Executor

Returns a new instance of Executor.



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

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

Class Method Details

.execute(command) ⇒ Object



7
8
9
10
11
12
# File 'lib/executor.rb', line 7

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

	[@output, @exit_code]
end

Instance Method Details

#executeObject



19
20
21
22
23
24
# File 'lib/executor.rb', line 19

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

	success?
end

#success?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/executor.rb', line 26

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