Method: CodeRay::Duo#initialize
- Defined in:
- lib/coderay/duo.rb
#initialize(lang = nil, format = nil, options = {}) ⇒ Duo
Create a new Duo, holding a lang and a format to highlight code.
simple:
CodeRay::Duo[:ruby, :html].highlight 'bla 42'
with options:
CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??'
alternative syntax without options:
CodeRay::Duo[:ruby => :statistic].encode 'class << self; end'
alternative syntax with options:
CodeRay::Duo[{ :ruby => :statistic }, :do => :something].encode 'abc'
The options are forwarded to scanner and encoder (see CodeRay.get_scanner_options).
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/coderay/duo.rb', line 37 def initialize lang = nil, format = nil, = {} if format.nil? && lang.is_a?(Hash) && lang.size == 1 @lang = lang.keys.first @format = lang[@lang] else @lang = lang @format = format end = end |