Class: Plywood::Command
- Inherits:
-
Object
- Object
- Plywood::Command
- Defined in:
- lib/plywood/command.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#err ⇒ Object
readonly
Returns the value of attribute err.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(name, command) ⇒ Command
constructor
A new instance of Command.
- #ios ⇒ Object
- #run ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, command) ⇒ Command
Returns a new instance of Command.
8 9 10 11 12 13 |
# File 'lib/plywood/command.rb', line 8 def initialize(name, command) @name = name.to_s @command = command.to_s @err, @err_writer = build_pipe(:err) @out, @out_writer = build_pipe(:out) end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/plywood/command.rb', line 5 def command @command end |
#err ⇒ Object (readonly)
Returns the value of attribute err.
6 7 8 |
# File 'lib/plywood/command.rb', line 6 def err @err end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/plywood/command.rb', line 5 def name @name end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
6 7 8 |
# File 'lib/plywood/command.rb', line 6 def out @out end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
6 7 8 |
# File 'lib/plywood/command.rb', line 6 def pid @pid end |
Instance Method Details
#ios ⇒ Object
19 20 21 |
# File 'lib/plywood/command.rb', line 19 def ios [err, out] end |
#run ⇒ Object
23 24 25 26 27 |
# File 'lib/plywood/command.rb', line 23 def run @pid = ::Process.spawn(@command, err: @err_writer, out: @out_writer) @err_writer.puts "started with pid #{@pid}" self end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/plywood/command.rb', line 15 def to_s "#{name} `#{@command}`" end |