Class: Eskimo::Components::Wrap
- Inherits:
-
Eskimo::Component
- Object
- Eskimo::Component
- Eskimo::Components::Wrap
- Defined in:
- lib/eskimo/components/wrap.rb
Overview
Wrap a block text with newlines at a certain threshold.
Wrap.new(width: 3) do
"foobar"
end
# => "foo"
# "bar"
Instance Attribute Summary collapse
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(width: Constants::SCREEN_COLUMNS, &children) ⇒ Wrap
constructor
A new instance of Wrap.
- #render ⇒ Object
Constructor Details
#initialize(width: Constants::SCREEN_COLUMNS, &children) ⇒ Wrap
Returns a new instance of Wrap
16 17 18 19 |
# File 'lib/eskimo/components/wrap.rb', line 16 def initialize(width: Constants::SCREEN_COLUMNS, &children) @width = width super end |
Instance Attribute Details
#width ⇒ Object (readonly)
Returns the value of attribute width
14 15 16 |
# File 'lib/eskimo/components/wrap.rb', line 14 def width @width end |
Instance Method Details
#render ⇒ Object
21 22 23 |
# File 'lib/eskimo/components/wrap.rb', line 21 def render(**) Strings.wrap(super, width) end |