Sha256: db3f7a40d88370823d7b231b2f58c73177a1e5830324fd1b5e54f26858b5b130

Contents?: true

Size: 919 Bytes

Versions: 3

Compression:

Stored size: 919 Bytes

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/KeepSkipBased.rb 8778 2005-09-26T04:34:48.103938Z ertai  $

module Uttk

  module Filters

    class KeepSkipBased < Id
      include Concrete # Abstract

      attr_reader :keep, :skip

      default_options.merge! :keep => %r{},           # Keep anything
                             :skip => %r{\A\Z}        # Skip only empty strings

      def initialize ( observers, options, &b )
        super
        @keep, @skip, @action = @options.values_at :keep, :skip, :action
      end


      def keep? ( node )
        node_s = node.to_s
        (node_s =~ @keep and node_s !~ @skip)
      end


      def skip? ( node )
        ! keep? node
      end

    end # class KeepSkipBased

  end # module Filters

end # module Uttk

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uttk-0.4.5.0 lib/uttk/filters/KeepSkipBased.rb
uttk-0.4.6.2 lib/uttk/filters/KeepSkipBased.rb
uttk-0.4.6.1 lib/uttk/filters/KeepSkipBased.rb