Class: Capybara::Selector::FilterSet

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/selector/filter_set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ FilterSet

Returns a new instance of FilterSet.



10
11
12
13
14
15
16
# File 'lib/capybara/selector/filter_set.rb', line 10

def initialize(name, &block)
  @name = name
  @descriptions = []
  @expression_filters = {}
  @node_filters = {}
  instance_eval(&block)
end

Instance Attribute Details

#descriptionsObject (readonly)

Returns the value of attribute descriptions.



8
9
10
# File 'lib/capybara/selector/filter_set.rb', line 8

def descriptions
  @descriptions
end

#expression_filtersObject (readonly)

Returns the value of attribute expression_filters.



8
9
10
# File 'lib/capybara/selector/filter_set.rb', line 8

def expression_filters
  @expression_filters
end

#node_filtersObject (readonly)

Returns the value of attribute node_filters.



8
9
10
# File 'lib/capybara/selector/filter_set.rb', line 8

def node_filters
  @node_filters
end

Class Method Details

.add(name, &block) ⇒ Object



41
42
43
# File 'lib/capybara/selector/filter_set.rb', line 41

def add(name, &block)
  all[name.to_sym] = FilterSet.new(name.to_sym, &block)
end

.allObject



37
38
39
# File 'lib/capybara/selector/filter_set.rb', line 37

def all
  @filter_sets ||= {} # rubocop:disable Naming/MemoizedInstanceVariableName
end

.remove(name) ⇒ Object



45
46
47
# File 'lib/capybara/selector/filter_set.rb', line 45

def remove(name)
  all.delete(name.to_sym)
end

Instance Method Details

#describe(&block) ⇒ Object



27
28
29
# File 'lib/capybara/selector/filter_set.rb', line 27

def describe(&block)
  descriptions.push block
end

#description(**options) ⇒ Object



31
32
33
34
# File 'lib/capybara/selector/filter_set.rb', line 31

def description(**options)
  opts = options_with_defaults(options)
  @descriptions.map { |desc| desc.call(opts).to_s }.join
end

#expression_filter(name, *types_and_options, &block) ⇒ Object



23
24
25
# File 'lib/capybara/selector/filter_set.rb', line 23

def expression_filter(name, *types_and_options, &block)
  add_filter(name, Filters::ExpressionFilter, *types_and_options, &block)
end

#node_filter(name, *types_and_options, &block) ⇒ Object Also known as: filter



18
19
20
# File 'lib/capybara/selector/filter_set.rb', line 18

def node_filter(name, *types_and_options, &block)
  add_filter(name, Filters::NodeFilter, *types_and_options, &block)
end