Class: Capybara::Selector::Filter
- Inherits:
-
Object
- Object
- Capybara::Selector::Filter
- Defined in:
- lib/capybara/selector.rb
Instance Method Summary collapse
- #default ⇒ Object
- #default? ⇒ Boolean
-
#initialize(name, block, options = {}) ⇒ Filter
constructor
A new instance of Filter.
- #matches?(node, value) ⇒ Boolean
Constructor Details
#initialize(name, block, options = {}) ⇒ Filter
Returns a new instance of Filter.
4 5 6 7 8 9 |
# File 'lib/capybara/selector.rb', line 4 def initialize(name, block, ={}) @name = name @block = block @options = @options[:valid_values] = [true,false] if [:boolean] end |
Instance Method Details
#default ⇒ Object
15 16 17 |
# File 'lib/capybara/selector.rb', line 15 def default @options[:default] end |
#default? ⇒ Boolean
11 12 13 |
# File 'lib/capybara/selector.rb', line 11 def default? @options.has_key?(:default) end |
#matches?(node, value) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/capybara/selector.rb', line 19 def matches?(node, value) if @options.has_key?(:valid_values) && !Array(@options[:valid_values]).include?(value) warn "Invalid value #{value.inspect} passed to filter #{@name}" end @block.call(node, value) end |