Class: CutePrint::Formatter Private

Inherits:
Object show all
Defined in:
lib/cute_print/formatter.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.

API:

  • private

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Formatter

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

API:

  • private



15
16
17
18
19
20
21
22
23
# File 'lib/cute_print/formatter.rb', line 15

def initialize(opts = {})
  @method = opts.fetch(:method)
  @out = opts.fetch(:out)
  @block = opts.fetch(:block, nil)
  @args = opts.fetch(:values, [])
  @values = Values.new(@args, @block)
  @width = opts.fetch(:width)
  @location_label = nil
end

Instance Method Details

#inspectObject

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.

API:

  • private



41
42
43
# File 'lib/cute_print/formatter.rb', line 41

def inspect
  @format = Format::Inspect.new
end

#pretty_printObject

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.

API:

  • private



45
46
47
# File 'lib/cute_print/formatter.rb', line 45

def pretty_print
  @format = Format::PrettyPrint.new
end

#with_location(format_key) ⇒ Object

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.

API:

  • private



36
37
38
39
# File 'lib/cute_print/formatter.rb', line 36

def with_location(format_key)
  location = Location.find
  @location_label = LocationLabel.make(format_key, location)
end

#writeObject

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.

API:

  • private



25
26
27
28
29
30
31
32
33
34
# File 'lib/cute_print/formatter.rb', line 25

def write
  if @values.empty? && !label.empty?
    write_line label.chomp(": ")
  else
    @values.each do |value|
      labeler = Labeler.new(@format, @width, label, value)
      write_lines labeler.labeled
    end
  end
end