Sha256: f653f56cc8ba9d420aa97c1df28745aa969240e45f3867fdf171f7cd0cf37a4b
Contents?: true
Size: 1.91 KB
Versions: 6
Compression:
Stored size: 1.91 KB
Contents
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. # Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved. # License:: LGPL # Revision:: $Id: /w/fey/uttk/trunk/lib/uttk/filters/TextFilter.rb 21844 2006-02-17T17:26:59.771162Z pouillar $ module Uttk module Filters class TextFilter < KeepSkipBased include Concrete default_options.merge! :action => nil # No default action # FIXME can be path based # This filter use the Text manipulation class of RubyEx. # You can apply transformation over leaves content. # # This filter takes two arguments: # - observers: An observer list like any filter # - options: # keep: A regular expression (all keys which match this regexp are transformed) # skip: Antoher regexp that skip keys which match # action: What transformation apply (e.g. justify), see the _Text_ class for # more informations # width: Maximal width of a line # # Examples: # Yaml syntax: 'TextFilter: [!keep "^(in|out)put$", !action justify, Yaml]' # def initialize ( observers, options, &b ) super @text_factory = MetaFactory.new(Text, @options) @filter_next_leaf = false end def new_node ( path, node ) @filter_next_leaf = keep? node.segment super end protected :new_node def new_leaf ( path, node ) super(path, (@filter_next_leaf)? node_filter(node) : node) end protected :new_leaf def up ( path ) @filter_next_leaf = false super end protected :up def node_filter ( anObject ) return anObject unless anObject.is_a? String o = @text_factory.create([anObject]) eval("o.#@action").text end protected :node_filter end # class TextFilter end # module Filters end # module Uttk
Version data entries
6 entries across 6 versions & 1 rubygems