diff .svn/pristine/b9/b982f3bb626cbc93a53ddb7f7ab16811202b4d33.svn-base @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.svn/pristine/b9/b982f3bb626cbc93a53ddb7f7ab16811202b4d33.svn-base	Fri Feb 24 19:09:32 2012 +0000
@@ -0,0 +1,58 @@
+module CodeRay
+module Encoders
+  
+  # A Filter encoder has another Tokens instance as output.
+  # It can be subclass to select, remove, or modify tokens in the stream.
+  # 
+  # Subclasses of Filter are called "Filters" and can be chained.
+  # 
+  # == Options
+  # 
+  # === :tokens
+  # 
+  # The Tokens object which will receive the output.
+  # 
+  # Default: Tokens.new
+  # 
+  # See also: TokenKindFilter
+  class Filter < Encoder
+    
+    register_for :filter
+    
+  protected
+    def setup options
+      super
+      
+      @tokens = options[:tokens] || Tokens.new
+    end
+    
+    def finish options
+      output @tokens
+    end
+    
+  public
+    
+    def text_token text, kind  # :nodoc:
+      @tokens.text_token text, kind
+    end
+    
+    def begin_group kind  # :nodoc:
+      @tokens.begin_group kind
+    end
+    
+    def begin_line kind  # :nodoc:
+      @tokens.begin_line kind
+    end
+    
+    def end_group kind  # :nodoc:
+      @tokens.end_group kind
+    end
+    
+    def end_line kind  # :nodoc:
+      @tokens.end_line kind
+    end
+    
+  end
+  
+end
+end