Class: Wrapomatic::Line::Processor::Base Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wrapomatic/line/processor/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.

Note:

To create a new Line processor, inherit from this class and implement the private method ‘processed`, returning a String

The base processor from which all other processors inherit

Examples:

Creating A New Line Processor

class MyProcessor < Wrapomatic::Line::Processor::Base
  private
  def processed
    "the conent that we want to pass back after processing"
  end
end

Direct Known Subclasses

Primary, Remainder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, columns) ⇒ Base

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 Base.

Parameters:

  • text (String)

    the text to process

  • columns (Integer)

    the column cutoff at which the line should be wrapped



30
31
32
# File 'lib/wrapomatic/line/processor/base.rb', line 30

def initialize(text, columns)
  @text, @columns = text, columns
end

Instance Attribute Details

#columnsInteger (readonly)

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 the maximum number of characters in the result.

Returns:

  • (Integer)

    the maximum number of characters in the result



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/wrapomatic/line/processor/base.rb', line 23

class Base
  attr_reader :text, :columns

  # @param text [String] the text to process
  #
  # @param columns [Integer] the column cutoff at which the line should
  #   be wrapped
  def initialize(text, columns)
    @text, @columns = text, columns
  end

  # The content after processing
  #
  # @return [String] the line part resulting from processing
  def content
    processed
  end

  private
  def processed
    text
  end
end

#textString (readonly)

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 the text being processed.

Returns:

  • (String)

    the text being processed



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/wrapomatic/line/processor/base.rb', line 23

class Base
  attr_reader :text, :columns

  # @param text [String] the text to process
  #
  # @param columns [Integer] the column cutoff at which the line should
  #   be wrapped
  def initialize(text, columns)
    @text, @columns = text, columns
  end

  # The content after processing
  #
  # @return [String] the line part resulting from processing
  def content
    processed
  end

  private
  def processed
    text
  end
end

Instance Method Details

#contentString

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 content after processing

Returns:

  • (String)

    the line part resulting from processing



37
38
39
# File 'lib/wrapomatic/line/processor/base.rb', line 37

def content
  processed
end