class Nokogiri::XML::Element

Public Instance Methods

next_until(method = :next_element) click to toggle source

Keep consuming elements until the block returns ‘true`.

@param [Symbol] method

The method to call on the current element to get the next one. The default
is to use `:next_element`. Use `:next` to include text elements in the
iteration.

@yield [Nokogiri::XML::Element] element

The current element. If the block returns `true` (or any non-false value)
then this is what the method will return.
# File lib/eagleclaw/xml.rb, line 16
def next_until(method = :next_element)
  current = self
  until yield(current)
    current = current.send(method)
  end
  current
end
next_while(method = :next_element) click to toggle source

Keep consuming elements until the block returns ‘false`.

The behaviour of this method is identical to {#next_until}, only it will keep iterating until the block yields a false value instead of a true one.

@see next_until

# File lib/eagleclaw/xml.rb, line 31
def next_while(method = :next_element)
  current = self
  while yield(current)
    current = current.send(method)
  end
  current
end