Class: Hanami::CLI::SystemCall::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/cli/system_call.rb

Overview

The result of a system call. Provides access to its standard out and error streams, plus whether the command executed successfully.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exit_code:, out:, err:) ⇒ Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Result.

Since:

  • 2.0.0



50
51
52
53
54
# File 'lib/hanami/cli/system_call.rb', line 50

def initialize(exit_code:, out:, err:)
  @exit_code = exit_code
  @out = out
  @err = err
end

Instance Attribute Details

#errIO (readonly)

Returns the command's error ouptut stream

Returns:

  • (IO)

Since:

  • 2.0.0



46
47
48
# File 'lib/hanami/cli/system_call.rb', line 46

def err
  @err
end

#exit_codeInteger (readonly)

Returns the command's exit code

Returns:

  • (Integer)

Since:

  • 2.0.0



30
31
32
# File 'lib/hanami/cli/system_call.rb', line 30

def exit_code
  @exit_code
end

#outIO (readonly)

Returns the command's standard output stream

Returns:

  • (IO)

Since:

  • 2.0.0



38
39
40
# File 'lib/hanami/cli/system_call.rb', line 38

def out
  @out
end

Instance Method Details

#successful?Boolean

Returns true if the command executed successfully (if its #exit_code is 0).

Returns:

  • (Boolean)

Since:

  • 2.0.0



62
63
64
# File 'lib/hanami/cli/system_call.rb', line 62

def successful?
  exit_code == SUCCESSFUL_EXIT_CODE
end