Class: ObjectiveCommand::Commands::Factory

Inherits:
Command show all
Defined in:
lib/objective_command/commands/factory.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #command, #dir, #error, #input, #open_mode, #output

Instance Method Summary collapse

Methods inherited from Command

#+, #<, #<<, #>, #>>, #[], #arg_string, #exec, #expand, #fork, #freeze, #inspect_for_unified_matchers, #instanciate_args, #instanciate_args!, #popen, #ruby, #run, #run_with_options, #sh, #sh!, #sh_args, #sys, #system, #to_a, #to_ocmd, #to_s, #to_sh, #whereis, #|

Constructor Details

#initializeFactory

Returns a new instance of Factory.



12
13
14
15
# File 'lib/objective_command/commands/factory.rb', line 12

def initialize
  super(nil)
  @command_class = Command
end

Instance Method Details

#new_command(*a, &b) ⇒ Object Also known as: create



17
18
19
20
21
22
23
24
# File 'lib/objective_command/commands/factory.rb', line 17

def new_command ( *a, &b )
  cmd = @command_class.new(*a, &b)
  instance_variables.each do |var|
    next if var =~ /^@command(_class)?$/
    cmd.send(var[1..-1] + '=', instance_variable_get(var))
  end
  cmd
end