class SystemCall::Command
A class responsible for communication with command line interfaces.
@!attribute [r] args
@return [Array]
Attributes
args[R]
Public Class Methods
call(*args)
click to toggle source
Initializes and calls a {Command}, then returns the {Result}.
@param args [Array] The command line arguments. @return [Result]
# File lib/system_call/command.rb, line 27 def self.call(*args) new(*args).call end
new(*args)
click to toggle source
Initializes a {Command}.
@param args [Array] The command line arguments.
# File lib/system_call/command.rb, line 18 def initialize(*args) @args = args.flatten end
Public Instance Methods
call()
click to toggle source
Invokes the {Command} and returns the {Result}.
@return [Result]
# File lib/system_call/command.rb, line 35 def call Open3.popen3(*args) do |_, stdout, stderr, wait_thr| success_result = readlines(stdout) error_result = readlines(stderr) exit_status = wait_thr.value Result.new(exit_status, success_result, error_result) end end
Private Instance Methods
readlines(io)
click to toggle source
# File lib/system_call/command.rb, line 46 def readlines(io) io.readlines.join.chomp end