class Capybara::Selector::FilterSet

def add(name, &block)

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

def add_filter(name, filter_class, *types, **options, &block)

def add_filter(name, filter_class, *types, **options, &block)
  types.each { |k| options[k] = true }
  filters[name] = filter_class.new(name, block, options)
end

def all

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

def describe(&block)

def describe(&block)
  descriptions.push block
end

def description(**options)

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

def expression_filter(name, *types_and_options, &block)

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

def expression_filters

def expression_filters
  filters.select { |_n, f| f.nil? || f.is_a?(Filters::ExpressionFilter) }.freeze
end

def filter(name, *types_and_options, &block)

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

def filters

def filters
  @filters ||= {}
end

def initialize(name, &block)

def initialize(name, &block)
  @name = name
  @descriptions = []
  instance_eval(&block)
end

def node_filters

def node_filters
  filters.reject { |_n, f| f.nil? || f.is_a?(Filters::ExpressionFilter) }.freeze
end

def options_with_defaults(options)

def options_with_defaults(options)
  options = options.dup
  filters.each do |name, filter|
    options[name] = filter.default if filter.default? && !options.key?(name)
  end
  options
end

def remove(name)

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