Class: System::CommandLine
- Inherits:
-
Object
- Object
- System::CommandLine
- Includes:
- Logue::Loggable
- Defined in:
- lib/system/command/line.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #<<(arg) ⇒ Object
- #execute ⇒ Object
-
#initialize(args = Array.new) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #to_command ⇒ Object
Constructor Details
#initialize(args = Array.new) ⇒ CommandLine
Returns a new instance of CommandLine.
18 19 20 |
# File 'lib/system/command/line.rb', line 18 def initialize args = Array.new @args = args.dup end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
13 14 15 |
# File 'lib/system/command/line.rb', line 13 def args @args end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
15 16 17 |
# File 'lib/system/command/line.rb', line 15 def error @error end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
14 15 16 |
# File 'lib/system/command/line.rb', line 14 def output @output end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
16 17 18 |
# File 'lib/system/command/line.rb', line 16 def status @status end |
Instance Method Details
#<<(arg) ⇒ Object
22 23 24 |
# File 'lib/system/command/line.rb', line 22 def << arg @args << arg end |
#execute ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/system/command/line.rb', line 26 def execute cmd = to_command debug "cmd: #{cmd}".color("8A8A43") Open3.popen3(cmd) do |stdin, stdout, stderr, wthr| @output = stdout.readlines @error = stderr.readlines @status = wthr.value end debug "@output: #{@output}" debug "@error: #{@error}" debug "@status: #{@status}" @output end |
#to_command ⇒ Object
43 44 45 |
# File 'lib/system/command/line.rb', line 43 def to_command @args.join ' ' end |