class Eskimo::ASCII::TruncateRear

Truncate text from the rear if it exceeds a certain width.

TruncateRear.new(width: 3) do
  "foo bar"
end
# => "foo..."

Public Instance Methods

render(render:, **) click to toggle source
# File lib/eskimo/ascii/components/truncate_rear.rb, line 13
def render(render:, **)
  text = render[@children]

  if text.length >= maxlen
    text[0..maxlen - 1] + '...'
  else
    text
  end
end