Class: Eskimo::Components::Style

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

Overview

Style text with colors and custom formatting.

See [Pastel’s documentation] for the accepted styles.

[pastel]: github.com/piotrmurach/pastel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*style, &children) ⇒ Style

Returns a new instance of Style.



50
51
52
53
54
55
# File 'lib/eskimo/components.rb', line 50

def initialize(*style, &children)
  @style = style.flatten
  @pastel = Pastel.new

  super(&children)
end

Instance Attribute Details

#pastelObject (readonly)

Returns the value of attribute pastel.



48
49
50
# File 'lib/eskimo/components.rb', line 48

def pastel
  @pastel
end

#styleObject (readonly)

Returns the value of attribute style.



48
49
50
# File 'lib/eskimo/components.rb', line 48

def style
  @style
end

Instance Method Details

#renderObject



57
58
59
# File 'lib/eskimo/components.rb', line 57

def render(**)
  pastel.decorate(super, *style)
end