Class: TTY::Markdown::Decorator Private
- Inherits:
-
Object
- Object
- TTY::Markdown::Decorator
- Defined in:
- lib/tty/markdown/decorator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Responsible for decorating text with theme element styles
Instance Method Summary collapse
-
#decorate(text, name) ⇒ String
Decorate text with theme element styles.
-
#decorate_each_line(text, name) ⇒ String
Decorate each text line with theme element styles.
-
#enabled? ⇒ Boolean
Detect whether text decoration is enabled.
-
#initialize(pastel, theme) ⇒ Decorator
constructor
Create a Decorator instance.
Constructor Details
#initialize(pastel, theme) ⇒ Decorator
Create a TTY::Markdown::Decorator instance
28 29 30 31 |
# File 'lib/tty/markdown/decorator.rb', line 28 def initialize(pastel, theme) @pastel = pastel @theme = theme end |
Instance Method Details
#decorate(text, name) ⇒ String
Decorate text with theme element styles
58 59 60 |
# File 'lib/tty/markdown/decorator.rb', line 58 def decorate(text, name) @pastel.decorate(text, *@theme[name]) end |
#decorate_each_line(text, name) ⇒ String
Decorate each text line with theme element styles
75 76 77 78 79 |
# File 'lib/tty/markdown/decorator.rb', line 75 def decorate_each_line(text, name) text.lines.map do |line| decorate(line.chomp, name) end.join(NEWLINE) end |
#enabled? ⇒ Boolean
Detect whether text decoration is enabled
41 42 43 |
# File 'lib/tty/markdown/decorator.rb', line 41 def enabled? @pastel.enabled? end |