Class: Capybara::Selector::FilterSet
- Inherits:
-
Object
- Object
- Capybara::Selector::FilterSet
- Defined in:
- lib/capybara/selector/filter_set.rb
Instance Attribute Summary collapse
-
#descriptions ⇒ Object
readonly
Returns the value of attribute descriptions.
-
#expression_filters ⇒ Object
readonly
Returns the value of attribute expression_filters.
-
#node_filters ⇒ Object
readonly
Returns the value of attribute node_filters.
Class Method Summary collapse
Instance Method Summary collapse
- #describe(&block) ⇒ Object
- #description(**options) ⇒ Object
- #expression_filter(name, *types_and_options, &block) ⇒ Object
-
#initialize(name, &block) ⇒ FilterSet
constructor
A new instance of FilterSet.
- #node_filter(name, *types_and_options, &block) ⇒ Object (also: #filter)
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
#descriptions ⇒ Object (readonly)
Returns the value of attribute descriptions.
8 9 10 |
# File 'lib/capybara/selector/filter_set.rb', line 8 def descriptions @descriptions end |
#expression_filters ⇒ Object (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_filters ⇒ Object (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 |
.all ⇒ Object
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(**) opts = () @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, *, &block) add_filter(name, Filters::ExpressionFilter, *, &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, *, &block) add_filter(name, Filters::NodeFilter, *, &block) end |