Class: Cuprum::Utils::ResultNotEmptyWarning

Inherits:
Object
  • Object
show all
Defined in:
lib/cuprum/utils/result_not_empty_warning.rb

Overview

Helper class for building a warning message when a command returns a result, but the command’s current result already has errors, a set status, or is halted.

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ ResultNotEmptyWarning

Returns a new instance of ResultNotEmptyWarning.

Parameters:

  • result (Cuprum::Result)

    The result for which to generate the warning message.



13
14
15
# File 'lib/cuprum/utils/result_not_empty_warning.rb', line 13

def initialize result
  @result = result
end

Instance Method Details

#messageString

Returns The warning message for the given result.

Returns:

  • (String)

    The warning message for the given result.



18
19
20
21
22
# File 'lib/cuprum/utils/result_not_empty_warning.rb', line 18

def message
  return ''.freeze if warnings.empty?

  MESSAGE + humanize_list(warnings).freeze
end

#warning?Boolean

Returns True if a warning is generated, otherwise false.

Returns:

  • (Boolean)

    True if a warning is generated, otherwise false.



25
26
27
# File 'lib/cuprum/utils/result_not_empty_warning.rb', line 25

def warning?
  !warnings.empty?
end