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