Method: PageMagic::Element::Selector#initialize

Defined in:
lib/page_magic/element/selector.rb

#initialize(selector = nil, supports_type: false, exact: false, &formatter) ⇒ Selector

Initialize a new selector a block can be supplied to decorate the query. E.g.

Examples:

Selector.new(supports_type: false) do |arg|
  "*[name='#{arg}']"
end

Parameters:

  • selector (Symbol) (defaults to: nil)

    the identifier for the selector

  • supports_type (Boolean) (defaults to: false)

    whether the element type being searched for can be used as part of the query

  • exact (Boolean) (defaults to: false)

    whether an exact match is required. E.g. element should include exactly the same text



38
39
40
41
42
43
44
45
# File 'lib/page_magic/element/selector.rb', line 38

def initialize(selector = nil, supports_type: false, exact: false, &formatter)
  @selector = selector
  @formatter = formatter || proc { |arg| arg }
  @supports_type = supports_type
  @options = {}.tap do |hash|
    hash[:exact] = true if exact
  end
end