Class: ObjectiveCommand::Commands::Seq
- Defined in:
- lib/objective_command/commands/seq.rb
Instance Attribute Summary
Attributes inherited from Command
#args, #command, #dir, #error, #input, #open_mode, #output
Instance Method Summary collapse
-
#initialize(*cmds) ⇒ Seq
constructor
A new instance of Seq.
- #run(*a) ⇒ Object
- #to_sh ⇒ Object
Methods inherited from Command
#+, #<, #<<, #>, #>>, #[], #arg_string, #exec, #expand, #fork, #freeze, #inspect_for_unified_matchers, #instanciate_args, #instanciate_args!, #popen, #ruby, #run_with_options, #sh, #sh!, #sh_args, #sys, #system, #to_a, #to_ocmd, #to_s, #whereis, #|
Constructor Details
#initialize(*cmds) ⇒ Seq
Returns a new instance of Seq.
12 13 14 15 |
# File 'lib/objective_command/commands/seq.rb', line 12 def initialize ( *cmds ) @cmds = cmds @input, @output, @error = nil, nil, nil end |
Instance Method Details
#run(*a) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/objective_command/commands/seq.rb', line 17 def run ( *a ) datas = [] @cmds.each do |cmd| datas.last.waitpid unless datas.empty? datas << cmd.run(*a) end Datas::Composite.new(datas) end |
#to_sh ⇒ Object
26 27 28 29 |
# File 'lib/objective_command/commands/seq.rb', line 26 def to_sh strs = @cmds.map { |cmd| "(#{cmd.to_sh})" } "(#{strs.join(' ; ')})#{sh_args}" end |