Class: CemAcpt::Utils::Shell::OutputData

Inherits:
Object
  • Object
show all
Defined in:
lib/cem_acpt/utils/shell.rb

Overview

Class to represent a single piece of output data, along with the stream it came from (stdout or stderr). This class is used to buffer output data from shell commands before writing it to the output stream, allowing for real-time logging and processing of the output.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, stream = :stdout) ⇒ OutputData

Initializes a new OutputData instance.

Parameters:

  • data (String)

    The output data captured from the shell command

  • stream (Symbol) (defaults to: :stdout)

    The stream the data came from, either :stdout or :stderr. Defaults to :stdout.



23
24
25
26
# File 'lib/cem_acpt/utils/shell.rb', line 23

def initialize(data, stream = :stdout)
  @data = data
  @stream = stream
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



18
19
20
# File 'lib/cem_acpt/utils/shell.rb', line 18

def data
  @data
end

#streamObject (readonly)

Returns the value of attribute stream.



18
19
20
# File 'lib/cem_acpt/utils/shell.rb', line 18

def stream
  @stream
end

Instance Method Details

#to_sString

Returns The string representation of the output data, which is just the data itself.

Returns:

  • (String)

    The string representation of the output data, which is just the data itself.



29
30
31
# File 'lib/cem_acpt/utils/shell.rb', line 29

def to_s
  data
end