class CodeRay::Duo

this method, since it takes care of everything.
Until you want to do uncommon things with CodeRay, I recommend to use
CodeRay::Duo[:python, :div].highlight ‘import this’
require ‘coderay’
task. It also provides a very easy interface syntax:
Duo makes it easy to re-use both scanner and encoder for a repetitive
output format), and call Duo#highlight with the code.
giving it a lang (language of the input code) and a format (desired
A Duo is a convenient way to use CodeRay. You just create a Duo,
= Duo

def encode code, options = {}

Tokenize and highlight the code using +scanner+ and +encoder+.
def encode code, options = {}
  options = @options.merge options
  encoder.encode(code, @lang, options)
end

def encoder

The encoder of the duo. Only created once.
def encoder
  @encoder ||= CodeRay.encoder @format, @options
end

def initialize lang = nil, format = nil, options = {}

(see CodeRay.get_scanner_options).
The options are forwarded to scanner and encoder

CodeRay::Duo[{ :ruby => :statistic }, :do => :something].encode 'abc'
alternative syntax with options:

CodeRay::Duo[:ruby => :statistic].encode 'class << self; end'
alternative syntax without options:

CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??'
with options:

CodeRay::Duo[:ruby, :html].highlight 'bla 42'
simple:

Create a new Duo, holding a lang and a format to highlight code.
def initialize lang = nil, format = nil, options = {}
  if format.nil? && lang.is_a?(Hash) && lang.size == 1
    @lang = lang.keys.first
    @format = lang[@lang]
  else
    @lang = lang
    @format = format
  end
  @options = options
end

def scanner

The scanner of the duo. Only created once.
def scanner
  @scanner ||= CodeRay.scanner @lang, CodeRay.get_scanner_options(@options)
end