class Nokogiri::XML::Node

def kwattr_add(attribute_name, keywords)

Since v1.11.0

node.kwattr_add("rel", ["nofollow", "noreferrer"]) # =>
node # =>

an Array argument.
*Example:* Ensure that a +Node+ has "nofollow" and "noreferrer" in its +rel+ attribute, via

node.kwattr_add("rel", "nofollow noreferrer") # =>
node # =>

pre-existing duplicate "nofollow" is not removed.
Note that "nofollow" is not added because it is already present. Note also that the

String argument.
*Example:* Ensure that a +Node+ has "nofollow" and "noreferrer" in its +rel+ attribute, via a

node.kwattr_add("rel", "nofollow") # =>
node.kwattr_add("rel", "nofollow") # =>
node # =>

Note that duplicates are not added.

*Example:* Ensure that a +Node+ has "nofollow" in its +rel+ attribute.

[Returns] +self+ (Nokogiri::XML::Node) for ease of chaining method calls.

it is created.
not be added. Any values not present will be added. If the named attribute does not exist,
whitespace-delimited values, or an Array of String values. Any values already present will
Keywords to be added to the attribute named +attribute_name+. May be a string containing
- +keywords+ (String, Array)
- +attribute_name+ (String) The name of the keyword attribute to be modified.
[Parameters]

See also #add_class, #kwattr_values, #kwattr_append, #kwattr_remove

{the "rel" attribute}[https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel].
contain CSS classes. But other keyword attributes exist, for instance
values. Perhaps the most familiar example of this is the HTML "class" attribute used to
A "keyword attribute" is a node attribute that contains a set of space-delimited

with #kwattr_append.
added. Note that any existing duplicates in the attribute values are not removed. Compare
Any values in +keywords+ that already exist in the Node's attribute values are _not_

Ensure that values are present in a keyword attribute.

kwattr_add(attribute_name, keywords) → self
:call-seq:
def kwattr_add(attribute_name, keywords)
  keywords = keywordify(keywords)
  current_kws = kwattr_values(attribute_name)
  new_kws = (current_kws + (keywords - current_kws)).join(" ")
  set_attribute(attribute_name, new_kws)
  self
end