Module: CukeSlicer::FilterHelpers

Includes:
MatchingHelpers
Included in:
ExtractionHelpers
Defined in:
lib/cuke_slicer/helpers/filter_helpers.rb

Instance Method Summary collapse

Methods included from MatchingHelpers

#and_filter_match, #filter_match, #matching_path?, #matching_tag?, #or_filter_match

Instance Method Details

#apply_custom_filter(elements, &block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/cuke_slicer/helpers/filter_helpers.rb', line 7

def apply_custom_filter(elements, &block)
  if block
    elements.reject! do |element|
      block.call(element)
    end
  end
end

#filter_excluded_paths(elements, filters) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/cuke_slicer/helpers/filter_helpers.rb', line 37

def filter_excluded_paths(elements, filters)
  if filters
    filters = [filters] unless filters.is_a?(Array)

    elements.reject! do |element|
      matching_path?(element, filters)
    end
  end
end

#filter_excluded_tags(elements, filters) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cuke_slicer/helpers/filter_helpers.rb', line 15

def filter_excluded_tags(elements, filters)
  if filters
    filters = [filters] unless filters.is_a?(Array)

    unless filters.empty?
      elements.reject! do |element|
        matching_tag?(element, filters)
      end
    end
  end
end

#filter_included_paths(elements, filters) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cuke_slicer/helpers/filter_helpers.rb', line 47

def filter_included_paths(elements, filters)
  if filters
    filters = [filters] unless filters.is_a?(Array)

    unless filters.empty?
      elements.keep_if do |element|
        matching_path?(element, filters)
      end
    end
  end
end

#filter_included_tags(elements, filters) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/cuke_slicer/helpers/filter_helpers.rb', line 27

def filter_included_tags(elements, filters)
  if filters
    filters = [filters] unless filters.is_a?(Array)

    elements.keep_if do |element|
      matching_tag?(element, filters)
    end
  end
end