Sha256: 617008d0df593192471f7b14a41751c207be0e5e962b96ca5c9324f43a87ed6f

Contents?: true

Size: 508 Bytes

Versions: 5

Compression:

Stored size: 508 Bytes

Contents

module XPath
  class Union
    include Enumerable

    attr_reader :expressions

    def initialize(*expressions)
      @expressions = expressions
    end

    def each(&block)
      expressions.each(&block)
    end

    def to_xpath(predicate=nil)
      expressions.map { |e| e.to_xpath(predicate) }.join(' | ')
    end

    def to_xpaths
      [to_xpath(:exact), to_xpath(:fuzzy)].uniq
    end

    def method_missing(*args)
      XPath::Union.new(*expressions.map { |e| e.send(*args) })
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
wgibbs-xpath-0.1.4 lib/xpath/union.rb
xpath-0.1.3 lib/xpath/union.rb
xpath-0.1.2 lib/xpath/union.rb
xpath-0.1.1 lib/xpath/union.rb
xpath-0.1.0 lib/xpath/union.rb