attribute_match(equality, value)
protected
Create a regular expression to match an attribute value based on the
equality operator (=, ^=, |=, etc).
Show source
def attribute_match(equality, value)
regexp = value.is_a?(Regexp) ? value : Regexp.escape(value.to_s)
case equality
when "=" then
Regexp.new("^#{regexp}$")
when "~=" then
Regexp.new("(^|\s)#{regexp}($|\s)")
when "^="
Regexp.new("^#{regexp}")
when "$="
Regexp.new("#{regexp}$")
when "*="
regexp.is_a?(Regexp) ? regexp : Regexp.new(regexp)
when "|=" then
Regexp.new("^#{regexp}($|\s)")
else
raise InvalidSelectorError, "Invalid operation/value" unless value.empty?
//
end
end