Flowdock
axe( elements, axe_name, rest ) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/rexml/quickpath.rb, line 106
                def QuickPath::axe( elements, axe_name, rest )
                        matches = []
                        matches = filter( elements.dup, rest ) if axe_name =~ /-or-self$/u
                        case axe_name
                        when /^descendant/u
                                elements.each do |element|
                                        matches |= filter( element.to_a, "descendant-or-self::#{rest}" ) if element.kind_of? Element
                                end
                        when /^ancestor/u
                                elements.each do |element|
                                        while element.parent
                                                matches << element.parent
                                                element = element.parent
                                        end
                                end
                                matches = filter( matches, rest )
                        when "self"
                                matches = filter( elements, rest )
                        when "child"
                                elements.each do |element|
                                        matches |= filter( element.to_a, rest ) if element.kind_of? Element
                                end
                        when "attribute"
                                elements.each do |element|
                                        matches << element.attributes[ rest ] if element.kind_of? Element
                                end
                        when "parent"
                                matches = filter(elements.collect{|element| element.parent}.uniq, rest)
                        when "following-sibling"
                                matches = filter(elements.collect{|element| element.next_sibling}.uniq,
                                        rest)
                        when "previous-sibling"
                                matches = filter(elements.collect{|element| 
                                        element.previous_sibling}.uniq, rest )
                        end
                        return matches.uniq
                end
Register or log in to add new notes.