Class: Kitchen::ElementEnumeratorFactory
- Defined in:
- lib/kitchen/element_enumerator_factory.rb
Overview
Builds specific subclasses of ElementEnumeratorBase
Instance Attribute Summary collapse
-
#default_css_or_xpath ⇒ Object
readonly
Returns the value of attribute default_css_or_xpath.
-
#detect_sub_element_class ⇒ Object
readonly
Returns the value of attribute detect_sub_element_class.
-
#enumerator_class ⇒ Object
readonly
Returns the value of attribute enumerator_class.
-
#sub_element_class ⇒ Object
readonly
Returns the value of attribute sub_element_class.
Instance Method Summary collapse
-
#build_within(enumerator_or_element, search_query: SearchQuery.new, reload: false) ⇒ ElementEnumeratorBase
Builds a new enumerator within the scope of the provided argument (either an enumerator or a class).
-
#initialize(enumerator_class:, default_css_or_xpath: nil, sub_element_class: nil, detect_sub_element_class: false) ⇒ ElementEnumeratorFactory
constructor
Creates a new instance.
-
#or_with(other_factory) ⇒ ElementEnumeratorFactory
Builds a new enumerator that finds elements matching either this factory’s or the provided factory’s selectors.
Constructor Details
#initialize(enumerator_class:, default_css_or_xpath: nil, sub_element_class: nil, detect_sub_element_class: false) ⇒ ElementEnumeratorFactory
Creates a new instance
24 25 26 27 28 29 30 |
# File 'lib/kitchen/element_enumerator_factory.rb', line 24 def initialize(enumerator_class:, default_css_or_xpath: nil, sub_element_class: nil, detect_sub_element_class: false) @default_css_or_xpath = default_css_or_xpath @sub_element_class = sub_element_class @enumerator_class = enumerator_class @detect_sub_element_class = detect_sub_element_class end |
Instance Attribute Details
#default_css_or_xpath ⇒ Object (readonly)
Returns the value of attribute default_css_or_xpath.
8 9 10 |
# File 'lib/kitchen/element_enumerator_factory.rb', line 8 def default_css_or_xpath @default_css_or_xpath end |
#detect_sub_element_class ⇒ Object (readonly)
Returns the value of attribute detect_sub_element_class.
11 12 13 |
# File 'lib/kitchen/element_enumerator_factory.rb', line 11 def detect_sub_element_class @detect_sub_element_class end |
#enumerator_class ⇒ Object (readonly)
Returns the value of attribute enumerator_class.
9 10 11 |
# File 'lib/kitchen/element_enumerator_factory.rb', line 9 def enumerator_class @enumerator_class end |
#sub_element_class ⇒ Object (readonly)
Returns the value of attribute sub_element_class.
10 11 12 |
# File 'lib/kitchen/element_enumerator_factory.rb', line 10 def sub_element_class @sub_element_class end |
Instance Method Details
#build_within(enumerator_or_element, search_query: SearchQuery.new, reload: false) ⇒ ElementEnumeratorBase
Builds a new enumerator within the scope of the provided argument (either an enumerator or a class). Accepts optional selectors to further limit the scope of results found.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/kitchen/element_enumerator_factory.rb', line 42 def build_within(enumerator_or_element, search_query: SearchQuery.new, reload: false) case enumerator_or_element when ElementBase build_within_element(enumerator_or_element, search_query: search_query, reload: reload) when ElementEnumeratorBase if enumerator_class != ElementEnumerator && !search_query.expects_substitution? raise "Query #{search_query} is missing the substitution character ('$') but " \ "is run with an enumerator #{enumerator_class.name} that has its own " \ "selectors for substitution." end build_within_other_enumerator(enumerator_or_element, search_query: search_query, reload: reload) end end |
#or_with(other_factory) ⇒ ElementEnumeratorFactory
Builds a new enumerator that finds elements matching either this factory’s or the provided factory’s selectors.
67 68 69 70 71 72 73 |
# File 'lib/kitchen/element_enumerator_factory.rb', line 67 def or_with(other_factory) self.class.new( default_css_or_xpath: [default_css_or_xpath, other_factory.default_css_or_xpath], enumerator_class: TypeCastingElementEnumerator, detect_sub_element_class: true ) end |