class CutePrint::InlineLabeler

@api private

Constants

INDENT

Public Class Methods

label(formatter, width, label, value) click to toggle source
# File lib/cute_print/inline_labeler.rb, line 5
def self.label(formatter, width, label, value)
  new(formatter, width, label, value).labeled
end
new(formatter, width, label, value) click to toggle source
# File lib/cute_print/inline_labeler.rb, line 9
def initialize(formatter, width, label, value)
  @formatter = formatter
  @width = width
  @label = label
  @value = value
end

Public Instance Methods

labeled() click to toggle source
# File lib/cute_print/inline_labeler.rb, line 16
def labeled
  [@label.rstrip + "\n"] + indented_lines
end

Private Instance Methods

indented_lines() click to toggle source
# File lib/cute_print/inline_labeler.rb, line 25
def indented_lines
  lines.map do |line|
    INDENT + line
  end
end
lines() click to toggle source
# File lib/cute_print/inline_labeler.rb, line 31
def lines
  @formatter.format(@width - INDENT.size, @value)
end