Class: Dispersion::Highlighter
- Inherits:
-
Object
- Object
- Dispersion::Highlighter
- Defined in:
- lib/dispersion/highlighter.rb
Instance Method Summary collapse
-
#initialize(code) ⇒ Highlighter
constructor
A new instance of Highlighter.
- #to_ansi(theme: nil) ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(code) ⇒ Highlighter
Returns a new instance of Highlighter.
5 6 7 8 9 |
# File 'lib/dispersion/highlighter.rb', line 5 def initialize(code) @code = code @annotations = Dispersion::Annotator.call(code) freeze end |
Instance Method Details
#to_ansi(theme: nil) ⇒ Object
11 12 13 |
# File 'lib/dispersion/highlighter.rb', line 11 def to_ansi(theme: nil) Dispersion::Formatters::ANSI.new(@code, annotations: @annotations, theme:).call end |
#to_html ⇒ Object
15 16 17 |
# File 'lib/dispersion/highlighter.rb', line 15 def to_html Dispersion::Formatters::HTML.new(@code, annotations: @annotations).call end |