Class: Eskimo::Components::Wrap

Inherits:
Eskimo::Component show all
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

Instance Method Summary collapse

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

#widthObject (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

#renderObject



21
22
23
# File 'lib/eskimo/components/wrap.rb', line 21

def render(**)
  Strings.wrap(super, width)
end