Class: SubshellCommand::Command
- Inherits:
-
Object
- Object
- SubshellCommand::Command
- Defined in:
- lib/subshell_command.rb
Instance Attribute Summary collapse
-
#command_string ⇒ Object
readonly
Returns the value of attribute command_string.
-
#current_directory ⇒ Object
Returns the value of attribute current_directory.
-
#env_hash ⇒ Object
readonly
Returns the value of attribute env_hash.
-
#failure_callback ⇒ Object
readonly
Returns the value of attribute failure_callback.
-
#redirect_stderr_to_stdout ⇒ Object
Returns the value of attribute redirect_stderr_to_stdout.
-
#success_callback ⇒ Object
readonly
Returns the value of attribute success_callback.
Instance Method Summary collapse
- #cmd=(command_string) ⇒ Object
- #env=(env_hash) ⇒ Object
-
#initialize(command_string) ⇒ Command
constructor
A new instance of Command.
- #on_failure=(callback) ⇒ Object
- #on_success=(callback) ⇒ Object
Constructor Details
#initialize(command_string) ⇒ Command
Returns a new instance of Command.
11 12 13 14 15 16 17 18 |
# File 'lib/subshell_command.rb', line 11 def initialize(command_string) @command_string = command_string @env_hash = {} @current_directory = Dir.pwd @success_callback = ->{} @failure_callback = ->{} @redirect_stderr_to_stdout = false end |
Instance Attribute Details
#command_string ⇒ Object (readonly)
Returns the value of attribute command_string.
6 7 8 |
# File 'lib/subshell_command.rb', line 6 def command_string @command_string end |
#current_directory ⇒ Object
Returns the value of attribute current_directory.
7 8 9 |
# File 'lib/subshell_command.rb', line 7 def current_directory @current_directory end |
#env_hash ⇒ Object (readonly)
Returns the value of attribute env_hash.
7 8 9 |
# File 'lib/subshell_command.rb', line 7 def env_hash @env_hash end |
#failure_callback ⇒ Object (readonly)
Returns the value of attribute failure_callback.
8 9 10 |
# File 'lib/subshell_command.rb', line 8 def failure_callback @failure_callback end |
#redirect_stderr_to_stdout ⇒ Object
Returns the value of attribute redirect_stderr_to_stdout.
9 10 11 |
# File 'lib/subshell_command.rb', line 9 def redirect_stderr_to_stdout @redirect_stderr_to_stdout end |
#success_callback ⇒ Object (readonly)
Returns the value of attribute success_callback.
8 9 10 |
# File 'lib/subshell_command.rb', line 8 def success_callback @success_callback end |
Instance Method Details
#cmd=(command_string) ⇒ Object
20 21 22 |
# File 'lib/subshell_command.rb', line 20 def cmd=(command_string) @command_string = command_string end |
#env=(env_hash) ⇒ Object
24 25 26 |
# File 'lib/subshell_command.rb', line 24 def env=(env_hash) @env_hash = env_hash end |
#on_failure=(callback) ⇒ Object
36 37 38 |
# File 'lib/subshell_command.rb', line 36 def on_failure=(callback) @failure_callback = callback end |
#on_success=(callback) ⇒ Object
32 33 34 |
# File 'lib/subshell_command.rb', line 32 def on_success=(callback) @success_callback = callback end |