Class: Uttk::Filters::NodeCut

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

Overview

FIXME Can be path based This filter cut nodes which match ‘keep’ but not ‘skip’

options:
    keep:  A regular expression (all keys which match this regexp are cut)
    skip:  Antoher regexp that skip keys which match
    prune: Completly cut all sub nodes of a cut one

Defined Under Namespace

Modules: Assertions

Instance Attribute Summary

Attributes inherited from KeepSkipBased

#keep, #skip

Instance Method Summary collapse

Methods inherited from KeepSkipBased

#keep?, #skip?

Methods inherited from Filter

composition

Methods inherited from Logger::Backend

#update

Constructor Details

#initialize(*a, &b) ⇒ NodeCut

Returns a new instance of NodeCut.



22
23
24
25
26
# File 'lib/uttk/filters/NodeCut.rb', line 22

def initialize ( *a, &b )
  super
  @pruning_path = Set.new
  @pruning_path_node = nil
end

Instance Method Details

#prune?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/uttk/filters/NodeCut.rb', line 68

def prune?
  @options[:prune]
end

#pruning_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
76
77
78
79
# File 'lib/uttk/filters/NodeCut.rb', line 73

def pruning_path? ( path )
  return false unless @pruning_path_node
  @pruning_path_node.each_with_index do |seg, i|
    return false if seg != path[i]
  end
  return true
end