Class Uttk::Filters::TextFilter
In: lib/uttk/filters/TextFilter.rb
Parent: KeepSkipBased

Methods

new   new_leaf   new_node   node_filter   up  

Included Modules

Concrete

Public Class methods

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]'

[Source]

# File lib/uttk/filters/TextFilter.rb, line 31
      def initialize ( observers, options, &b )
        super
        @text_factory = MetaFactory.new(Text, @options)
        @filter_next_leaf = false
      end

Protected Instance methods

[Source]

# File lib/uttk/filters/TextFilter.rb, line 45
      def new_leaf ( path, node )
        super(path, (@filter_next_leaf)? node_filter(node) : node)
      end

[Source]

# File lib/uttk/filters/TextFilter.rb, line 38
      def new_node ( path, node )
        @filter_next_leaf = keep? node.segment
        super
      end

[Source]

# File lib/uttk/filters/TextFilter.rb, line 58
      def node_filter ( anObject )
        return anObject unless anObject.is_a? String
        o = @text_factory.create([anObject])
        eval("o.#@action").text
      end

[Source]

# File lib/uttk/filters/TextFilter.rb, line 51
      def up ( path )
        @filter_next_leaf = false
        super
      end

[Validate]