Class: ConvenientService::Service::Plugins::RescuesResultUnhandledExceptions::Commands::FormatMessage

Inherits:
ConvenientService::Support::Command show all
Defined in:
lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ConvenientService::Support::Command

[], call

Constructor Details

#initialize(message:) ⇒ void

Parameters:

  • message (String, nil)


24
25
26
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb', line 24

def initialize(message:)
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



18
19
20
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb', line 18

def message
  @message
end

Instance Method Details

#callString

Note:

Message formatting is inspired by RSpec. It has almost the same output (at least for RSpec 3).

Note:

Underscores are used to highlight spaces in docs, they are NOT included in the resulting message, check FormatException for a full example.

Examples:

Message.

__exception message

Multiline message.

__exception message first line
__exception message second line
__exception message third line

Returns:

  • (String)

See Also:



45
46
47
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/commands/format_message.rb', line 45

def call
  message.to_s.chomp.split("\n").map { |line| line.prepend(Constants::MESSAGE_LINE_PREFIX) }.join("\n")
end