Class: SubstitutionContext
- Inherits:
-
Object
- Object
- SubstitutionContext
- Defined in:
- lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
Instance Method Summary collapse
-
#initialize ⇒ SubstitutionContext
constructor
A new instance of SubstitutionContext.
- #match(matches, attribute, matcher) ⇒ Object
- #substitute!(selector, values, format_for_presentation = false) ⇒ Object
Constructor Details
#initialize ⇒ SubstitutionContext
Returns a new instance of SubstitutionContext.
2 3 4 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb', line 2 def initialize @substitute = '?' end |
Instance Method Details
#match(matches, attribute, matcher) ⇒ Object
16 17 18 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb', line 16 def match(matches, attribute, matcher) matches.find_all { |node| node[attribute] =~ Regexp.new(matcher) } end |
#substitute!(selector, values, format_for_presentation = false) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb', line 6 def substitute!(selector, values, format_for_presentation = false) selector = selector.dup while !values.empty? && substitutable?(values.first) && selector.index(@substitute) selector.sub! @substitute, matcher_for(values.shift, format_for_presentation) end selector end |