Module: CommandExec::FieldHelper

Included in:
CommandExec::Formatter::Array, CommandExec::Formatter::Hash, Process
Defined in:
lib/command_exec/field_helper.rb

Overview

Shared methods for fields

Instance Method Summary collapse

Instance Method Details

#end_time(value) ⇒ Array

Set the end time of command execution

Parameters:

  • value (Time)

    the end time of command execution

Returns:

  • (Array)

    the end time



259
260
261
# File 'lib/command_exec/field_helper.rb', line 259

def end_time(value)
  @end_time[0] = value
end

#executable(value) ⇒ Array

Set the path to the executable of the command

Parameters:

  • value (String)

    the path to the executable

Returns:

  • (Array)

    the executable



237
238
239
# File 'lib/command_exec/field_helper.rb', line 237

def executable(value)
  @executable[0] = value
end

#initializeObject

Initialize helper

will be used from array and hash via super call although there's no inheritance. See for more information http://stackoverflow.com/questions/1645398/ruby-include-question



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/command_exec/field_helper.rb', line 13

def initialize
  @end_time = []
  @executable = []
  @log_file = []
  @pid = []
  @reason_for_failure = []
  @return_code = []
  @start_time = []
  @status = []
  @stderr = []
  @stdout = []
end

#log_file(*content) ⇒ Array

Set the content of the log file

Parameters:

  • content (Array, String)

    The content of log file

Returns:

  • (Array)

    the content of the log file



172
173
174
# File 'lib/command_exec/field_helper.rb', line 172

def log_file(*content)
  @log_file += content.flatten
end

#pid(value) ⇒ Array

Set the pid of the command

Parameters:

  • value (Number, String)

    Set the pid of the command.

Returns:

  • (Array)


214
215
216
217
218
# File 'lib/command_exec/field_helper.rb', line 214

def pid(value)
  @pid[0] = value.to_s

  @pid
end

#reason_for_failure(*content) ⇒ Array

Set the reason for failure

Parameters:

  • content (Array, String)

    Set the reason for failure.

Returns:

  • (Array)


226
227
228
# File 'lib/command_exec/field_helper.rb', line 226

def reason_for_failure(*content)
  @reason_for_failure += content.flatten
end

#return_code(value) ⇒ Array

Set the return code of the command

Parameters:

  • value (Number, String)

    Set the return code(s) of the command.

Returns:

  • (Array)

    the return code



182
183
184
185
186
# File 'lib/command_exec/field_helper.rb', line 182

def return_code(value)
  @return_code[0] = value.to_s

  @return_code
end

#start_time(value) ⇒ Array

Set the start time of command execution

Parameters:

  • value (Time)

    the start time of command execution

Returns:

  • (Array)

    the start time



248
249
250
# File 'lib/command_exec/field_helper.rb', line 248

def start_time(value)
  @start_time[0] = value
end

#stderr(*content) ⇒ Array

Set the content of stderr

Parameters:

  • content (Array, String)

    The content of stderr

Returns:

  • (Array)


204
205
206
# File 'lib/command_exec/field_helper.rb', line 204

def stderr(*content)
  @stderr += content.flatten
end

#stdout(*content) ⇒ Array

Set the content of stdout

Parameters:

  • content (Array, String)

    The content of stdout

Returns:

  • (Array)


194
195
196
# File 'lib/command_exec/field_helper.rb', line 194

def stdout(*content)
  @stdout += content.flatten
end