class CodeRay::TokensProxy
while still providing the benefits of direct streaming.
This proxy makes it possible to use the classic CodeRay.scan.encode API
The result of a scan operation is a TokensProxy, but should act like Tokens.
def each *args, &blk
def each *args, &blk tokens.each(*args, &blk) self end
def encode encoder, options = {}
Call CodeRay.encode if +encoder+ is a Symbol;
def encode encoder, options = {} if encoder.respond_to? :to_sym CodeRay.encode(input, lang, encoder, options) else encoder.encode_tokens tokens, options end end
def initialize input, lang, options = {}, block = nil
def initialize input, lang, options = {}, block = nil @input = input @lang = lang @options = options @block = block end
def method_missing method, *args, &blk
Tries to call encode;
def method_missing method, *args, &blk encode method.to_sym, *args rescue PluginHost::PluginNotFound tokens.send(method, *args, &blk) end
def scanner
def scanner @scanner ||= CodeRay.scanner(lang, options, &block) end
def tokens
def tokens @tokens ||= scanner.tokenize(input) end