Class: Eskimo::ASCII::Style

Inherits:
Component show all
Defined in:
lib/eskimo/ascii/components/style.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.



12
13
14
15
16
17
# File 'lib/eskimo/ascii/components/style.rb', line 12

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

  super
end

Instance Attribute Details

#pastelObject (readonly)

Returns the value of attribute pastel.



10
11
12
# File 'lib/eskimo/ascii/components/style.rb', line 10

def pastel
  @pastel
end

#styleObject (readonly)

Returns the value of attribute style.



10
11
12
# File 'lib/eskimo/ascii/components/style.rb', line 10

def style
  @style
end

Instance Method Details

#renderObject



19
20
21
# File 'lib/eskimo/ascii/components/style.rb', line 19

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