Class: Uttk::Filters::KeepSkipBased

Inherits:
Id show all
Includes:
Concrete
Defined in:
lib/uttk/filters/KeepSkipBased.rb

Direct Known Subclasses

NodeCut, TextFilter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Filter

composition, #notif

Methods inherited from Logger::Backend

#update

Constructor Details

#initialize(observers, options, &b) ⇒ KeepSkipBased

Returns a new instance of KeepSkipBased.



18
19
20
21
# File 'lib/uttk/filters/KeepSkipBased.rb', line 18

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

Instance Attribute Details

#keepObject (readonly)

Returns the value of attribute keep.



13
14
15
# File 'lib/uttk/filters/KeepSkipBased.rb', line 13

def keep
  @keep
end

#skipObject (readonly)

Returns the value of attribute skip.



13
14
15
# File 'lib/uttk/filters/KeepSkipBased.rb', line 13

def skip
  @skip
end

Instance Method Details

#keep?(node) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/uttk/filters/KeepSkipBased.rb', line 24

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

#skip?(node) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/uttk/filters/KeepSkipBased.rb', line 30

def skip? ( node )
  ! keep? node
end