Class: CodeKindly::Utils::Command
- Inherits:
-
Object
- Object
- CodeKindly::Utils::Command
show all
- Includes:
- Presence
- Defined in:
- lib/code_kindly/utils/command.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Presence
blank?, #blank?, present?, #present?
Constructor Details
#initialize(command) ⇒ Command
16
17
18
|
# File 'lib/code_kindly/utils/command.rb', line 16
def initialize(command)
@command = command
end
|
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
14
15
16
|
# File 'lib/code_kindly/utils/command.rb', line 14
def command
@command
end
|
Class Method Details
.run(command) ⇒ Object
9
10
11
|
# File 'lib/code_kindly/utils/command.rb', line 9
def run(command)
new(command).run
end
|
Instance Method Details
#result ⇒ Object
28
29
30
31
32
|
# File 'lib/code_kindly/utils/command.rb', line 28
def result
return nil if blank? @std_out
@std_out.chomp!
blank? @std_out ? nil : @std_out
end
|
#run ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/code_kindly/utils/command.rb', line 20
def run
require 'open3'
command = @command
command.join(' ') if command.is_a?(Array)
@std_in, @std_out, @std_err = Open3.capture3(command)
self
end
|