| Class | Uttk::Filters::TextFilter |
| In: |
lib/uttk/filters/TextFilter.rb
|
| Parent: | KeepSkipBased |
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]'
# 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
# File lib/uttk/filters/TextFilter.rb, line 45 def new_leaf ( path, node ) super(path, (@filter_next_leaf)? node_filter(node) : node) end
# File lib/uttk/filters/TextFilter.rb, line 38 def new_node ( path, node ) @filter_next_leaf = keep? node.segment super end
# 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