Class: Cape::Deprecation::Base Abstract Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cape/deprecation/base.rb

Overview

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

This class is abstract.

Prints to a stream a message related to deprecated API usage.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#streamIO

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.

The stream to which deprecation messages are printed. Defaults to $stderr.

Returns:

  • (IO)


43
44
45
# File 'lib/cape/deprecation/base.rb', line 43

def stream
  @stream ||= $stderr
end

Instance Method Details

#formatted_messageString

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.

Formats #message_content for display.

Returns:

  • (String)

    the full message



22
23
24
25
26
27
28
# File 'lib/cape/deprecation/base.rb', line 22

def formatted_message
  [].tap do |fragments|
    fragments << XTerm.bold_and_foreground_red('*** DEPRECATED:')
    fragments << ' '
    fragments << XTerm.bold(message_content)
  end.join
end

#message_contentObject

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.

This method is abstract.

Prepares a message based on deprecated API usage.

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/cape/deprecation/base.rb', line 35

def message_content
  raise ::NotImplementedError
end

#write_formatted_message_to_streamBase

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.

Writes #formatted_message to #stream.

Returns:

  • (Base)

    the object



50
51
52
53
# File 'lib/cape/deprecation/base.rb', line 50

def write_formatted_message_to_stream
  stream.puts formatted_message
  self
end