diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2011-09-18 22:24:06 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2011-09-18 22:24:06 +0200 |
commit | a6b256219d84022fc518d620b210754b5f8ccce4 (patch) | |
tree | 0e99a1016c548e5bba3ffeea0ff327bbde42af76 /lib/coderay/tokens_proxy.rb | |
parent | 13e31231833ac7236b90a9680fef334c2ed6136d (diff) | |
download | coderay-a6b256219d84022fc518d620b210754b5f8ccce4.tar.gz |
#352 CodeRay.scan returns TokensProxy
Diffstat (limited to 'lib/coderay/tokens_proxy.rb')
-rw-r--r-- | lib/coderay/tokens_proxy.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/coderay/tokens_proxy.rb b/lib/coderay/tokens_proxy.rb new file mode 100644 index 0000000..598ad2e --- /dev/null +++ b/lib/coderay/tokens_proxy.rb @@ -0,0 +1,27 @@ +module CodeRay + + class TokensProxy < Struct.new :code, :lang, :options, :block + + def method_missing method, *args, &blk + tokens.send(method, *args, &blk) + end + + def tokens + @tokens ||= scanner.tokenize(code) + end + + def each *args, &blk + tokens.each(*args, &blk) + end + + def count + tokens.count + end + + def scanner + @scanner ||= CodeRay.scanner(lang, options, &block) + end + + end + +end |