Class: Eskimo::Components::TruncateRear
- Inherits:
-
Truncate
- Object
- Eskimo::Component
- Truncate
- Eskimo::Components::TruncateRear
- Defined in:
- lib/eskimo/components/truncate_rear.rb
Overview
Truncate text from the rear if it exceeds a certain width.
TruncateRear.new(width: 3) do
"foo bar"
end
# => "foo..."
Instance Attribute Summary
Attributes inherited from Truncate
Instance Method Summary collapse
Methods inherited from Truncate
Methods inherited from Eskimo::Component
Constructor Details
This class inherits a constructor from Eskimo::Components::Truncate
Instance Method Details
#render(render:) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/eskimo/components/truncate_rear.rb', line 14 def render(render:, **) text = render[@children] if text.length >= maxlen text[0..maxlen - 1] + '...' else text end end |