Module: Asciidoctor::SyntaxHighlighter::Factory
- Included in:
- CustomFactory, DefaultFactory
- Defined in:
- lib/asciidoctor/syntax_highlighter.rb
Instance Method Summary collapse
-
#create(name, backend = 'html5', opts = {}) ⇒ SyntaxHighlighter
Resolves the name to a syntax highlighter instance, if found in the registry.
-
#for(name) ⇒ Object
Retrieves the syntax highlighter class or object registered for the specified name.
-
#register(syntax_highlighter, *names) ⇒ void
Associates the syntax highlighter class or object with the specified names.
Instance Method Details
#create(name, backend = 'html5', opts = {}) ⇒ SyntaxHighlighter
Resolves the name to a syntax highlighter instance, if found in the registry.
147 148 149 150 151 152 153 |
# File 'lib/asciidoctor/syntax_highlighter.rb', line 147 def create name, backend = 'html5', opts = {} if (syntax_hl = self.for name) syntax_hl = syntax_hl.new name, backend, opts if ::Class === syntax_hl raise ::NameError, %(#{syntax_hl.class} must specify a value for `name') unless syntax_hl.name syntax_hl end end |
#for(name) ⇒ Object
Retrieves the syntax highlighter class or object registered for the specified name.
135 136 137 |
# File 'lib/asciidoctor/syntax_highlighter.rb', line 135 def for name registry[name] end |
#register(syntax_highlighter, *names) ⇒ void
This method returns an undefined value.
Associates the syntax highlighter class or object with the specified names.
126 127 128 |
# File 'lib/asciidoctor/syntax_highlighter.rb', line 126 def register syntax_highlighter, *names names.each {|name| registry[name] = syntax_highlighter } end |