Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v4.1.8) is shown here.
attribute_match(equality, value)protected
Create a regular expression to match an attribute value based on the equality operator (=, ^=, |=, etc).
# File actionview/lib/action_view/vendor/html-scanner/html/selector.rb, line 689
def attribute_match(equality, value)
regexp = value.is_a?(Regexp) ? value : Regexp.escape(value.to_s)
case equality
when "=" then
# Match the attribute value in full
Regexp.new("^#{regexp}$")
when "~=" then
# Match a space-separated word within the attribute value
Regexp.new("(^|\s)#{regexp}($|\s)")
when "^="
# Match the beginning of the attribute value
Regexp.new("^#{regexp}")
when "$="
# Match the end of the attribute value
Regexp.new("#{regexp}$")
when "*="
# Match substring of the attribute value
regexp.is_a?(Regexp) ? regexp : Regexp.new(regexp)
when "|=" then
# Match the first space-separated item of the attribute value
Regexp.new("^#{regexp}($|\s)")
else
raise InvalidSelectorError, "Invalid operation/value" unless value.empty?
# Match all attributes values (existence check)
//
end
end Related methods
- Instance methods
- match
- next_element
- select
- select_first
- to_s
- Class methods
- for_class
- for_id
- new
- Protected methods
-
attribute_match -
next_selector -
nth_child -
only_child -
simple_selector