Class: Console::Event::Spawn
- Defined in:
- lib/console/event/spawn.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #chdir_string(options) ⇒ Object
- #format(output, terminal, verbose) ⇒ Object
-
#initialize(environment, *arguments, **options) ⇒ Spawn
constructor
A new instance of Spawn.
Constructor Details
#initialize(environment, *arguments, **options) ⇒ Spawn
Returns a new instance of Spawn.
34 35 36 37 38 |
# File 'lib/console/event/spawn.rb', line 34 def initialize(environment, *arguments, **) @environment = environment @arguments = arguments @options = end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
41 42 43 |
# File 'lib/console/event/spawn.rb', line 41 def arguments @arguments end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
40 41 42 |
# File 'lib/console/event/spawn.rb', line 40 def environment @environment end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
42 43 44 |
# File 'lib/console/event/spawn.rb', line 42 def @options end |
Class Method Details
.for(*arguments, **options) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/console/event/spawn.rb', line 26 def self.for(*arguments, **) if arguments.first.is_a?(Hash) self.new(*arguments, **) else self.new(nil, arguments, **) end end |
.register(terminal) ⇒ Object
50 51 52 |
# File 'lib/console/event/spawn.rb', line 50 def self.register(terminal) terminal[:shell_command] ||= terminal.style(:blue, nil, :bold) end |
Instance Method Details
#chdir_string(options) ⇒ Object
44 45 46 47 48 |
# File 'lib/console/event/spawn.rb', line 44 def chdir_string() if and chdir = [:chdir] " in #{chdir}" end end |
#format(output, terminal, verbose) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/console/event/spawn.rb', line 54 def format(output, terminal, verbose) arguments = @arguments.flatten.collect(&:to_s) output.puts " #{terminal[:shell_command]}#{arguments.join(' ')}#{terminal.reset}#{chdir_string()}" if verbose and @environment @environment.each do |key, value| output.puts " export #{key}=#{value}" end end end |