Class: SubshellCommand::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/subshell_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_stringObject (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_directoryObject

Returns the value of attribute current_directory.



7
8
9
# File 'lib/subshell_command.rb', line 7

def current_directory
  @current_directory
end

#env_hashObject (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_callbackObject (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_stdoutObject

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_callbackObject (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