module Hpricot::Container::Trav
def siblings_at(*pos)
Like the other "sibling" methods, this doesn't find text and comment nodes.
ele.siblings_at(0, 5..6) # the current element and two others
ele.siblings_at(1, 5, 7) # gets three elements at offsets below the current element
ele.siblings_at(-3..-1, 1..3) # gets three elements before and three after
This method accepts ranges and sets of numbers.
to this element.
Puts together an array of neighboring sibling elements based on their proximity
def siblings_at(*pos) sib = parent.containers i, si = 0, sib.index(self) Elements[* sib.select do |x| sel = case i - si when *pos true end i += 1 sel end ] end