Class: TTY::Markdown::Theme Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/markdown/theme.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 storing the theme configuration

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theme) ⇒ Theme

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a TTY::Markdown::Theme instance

Parameters:

  • theme (Hash{Symbol => Array<Symbol>})

    the theme configuration



138
139
140
# File 'lib/tty/markdown/theme.rb', line 138

def initialize(theme)
  @theme = theme
end

Class Method Details

.from(theme) ⇒ TTY::Markdown::Theme

Create a TTY::Markdown::Theme instance

Examples:

theme = TTY::Markdown::Theme.from({comment: :blue})
theme = TTY::Markdown::Theme.from({comment: %i[blue underline]})

Parameters:

  • theme (Hash{Symbol => Array<String, Symbol>, String, Symbol})

    the theme configuration

Returns:

Raises:



55
56
57
# File 'lib/tty/markdown/theme.rb', line 55

def self.from(theme)
  new(validate_names(build_theme(theme)))
end

Instance Method Details

#[](name) ⇒ Array<Symbol>

Fetch styles by element name

Examples:

theme[:comment]

Parameters:

  • name (Symbol)

    the element name

Returns:

  • (Array<Symbol>)


154
155
156
# File 'lib/tty/markdown/theme.rb', line 154

def [](name)
  @theme[name]
end