Guess what this is

Ruby code posted by Jay
created at 09 Aug 16:20, updated at 09 Aug 19:05

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module CodeRay
  
  # = Duo
  #
  # $Id: scanner.rb 123 2006-03-21 14:46:34Z murphy $
  #
  # TODO: Doc.
  class Duo

    attr_accessor :scanner, :encoder

    def initialize lang, format, options = {}
      @scanner = CodeRay.scanner lang, CodeRay.get_scanner_options(options)
      @encoder = CodeRay.encoder format, options
    end

    class << self
      alias [] new
    end

    def encode code
      @scanner.string = code
      @encoder.encode_tokens(scanner.tokenize)
    end
    alias highlight encode

  end

end
552 Bytes in 2 ms with coderay