class Eskimo::ASCII::Component
A base component class that renders child components defined in a block into a String for further formatting.
class MyComponent < Eskimo::ASCII::Component def render(**) text = super text.is_a?(String) # => true end end
Use of this class is optional. What's happening under the hood is:
-
Component
maintains a reference to the Proc passed to {#initialize}. That Proc can potentially return a list of child components to render. -
{Component#render} (called via “super” from sub-classes) invokes the `render` prop provided by {Core::Renderer#apply} with the tracked children which converts them to a String and returns them.
Public Class Methods
new(*, **, &children_gen)
click to toggle source
# File lib/eskimo/ascii/component.rb, line 23 def initialize(*, **, &children_gen) @children = children_gen end
Public Instance Methods
render(render:, **)
click to toggle source
# File lib/eskimo/ascii/component.rb, line 27 def render(render:, **) render[@children] end
Protected Instance Methods
pastel()
click to toggle source
# File lib/eskimo/ascii/component.rb, line 33 def pastel @pastel ||= Pastel.new end