module Nokogiri::CSS

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/nokogiri/css.rbs

module Nokogiri::CSS
  def xpath_for: (String selector, ?Hash options) -> untyped
end

def parse(selector) # :nodoc:

:nodoc:
It is not used by Nokogiri and shouldn't be part of the public API.
TODO: Deprecate this method ahead of 2.0 and delete it in 2.0.
def parse(selector) # :nodoc:
  Parser.new.parse(selector)
end

def xpath_for(selector, options = {})

Experimental RBS support (using type sampling data from the type_fusion project).

def xpath_for: (String selector, ?(prefix | String | ns | xmlns | String | xmlns:xlink | String | visitor | Nokogiri::CSS::XPathVisitor | prefix | String | ns | xmlns | String | visitor | Nokogiri::CSS::XPathVisitor) options) -> untyped

This signature was generated using 6 samples from 1 application.


💡 Note that translated queries are cached for performance concerns.

[Returns] (String) The equivalent XPath query for +selector+

the namespace prefix and the values are the namespace URIs. Default is an empty Hash.
The namespaces that are referenced in the query, if any. This is a hash where the keys are

- +ns:+ (Hash)

+Nokogiri::CSS::XPathVisitor.new+.
The visitor class to use to transform the AST into XPath. Default is

- +visitor:+ (Nokogiri::CSS::XPathVisitor)

+XML::XPath::GLOBAL_SEARCH_PREFIX+.
The XPath prefix for the query, see Nokogiri::XML::XPath for some options. Default is

- +prefix:+ (String)

- +selector+ (String) The CSS selector to be translated into XPath
[Parameters]

Translate a CSS selector to the equivalent XPath query.

xpath_for(selector [, prefix:] [, visitor:] [, ns:]) → String
xpath_for(selector) → String
:call-seq:
def xpath_for(selector, options = {})
  raise TypeError, "no implicit conversion of #{selector.inspect} to String" unless selector.respond_to?(:to_str)
  selector = selector.to_str
  raise Nokogiri::CSS::SyntaxError, "empty CSS selector" if selector.empty?
  prefix = options.fetch(:prefix, Nokogiri::XML::XPath::GLOBAL_SEARCH_PREFIX)
  visitor = options.fetch(:visitor) { Nokogiri::CSS::XPathVisitor.new }
  ns = options.fetch(:ns, {})
  Parser.new(ns).xpath_for(selector, prefix, visitor)
end