Sha256: 2cfef4a23b8e59db865affabf916d18c417945634377a2d7752f40a5a0fb7475

Contents?: true

Size: 917 Bytes

Versions: 3

Compression:

Stored size: 917 Bytes

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2005 Uttk Team. All rights reserved.
# License::   LGPL
# Revision::  $Id: /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.3.1.2 lib/uttk/filters/KeepSkipBased.rb
uttk-0.3.6.1 lib/uttk/filters/KeepSkipBased.rb
uttk-0.3.5.0 lib/uttk/filters/KeepSkipBased.rb