Class: Eskimo::Components::Wrap

Inherits:
Eskimo::Component show all
Defined in:
lib/eskimo/components.rb

Overview

Wrap a block text with newlines at a certain threshold.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width: SCREEN_COLUMNS, &children) ⇒ Wrap

Returns a new instance of Wrap.



104
105
106
107
# File 'lib/eskimo/components.rb', line 104

def initialize(width: SCREEN_COLUMNS, &children)
  @width = width
  super(&children)
end

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width.



102
103
104
# File 'lib/eskimo/components.rb', line 102

def width
  @width
end

Instance Method Details

#renderObject



109
110
111
# File 'lib/eskimo/components.rb', line 109

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