Sha256: 43efb0a07b6fe788a915f410bed2200e9906b5d8291f6866e10c18cbb1410085

Contents?: true

Size: 558 Bytes

Versions: 12

Compression:

Stored size: 558 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_s
      to_xpaths.join(' | ')
    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

12 entries across 12 versions & 3 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/lib/xpath/union.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/lib/xpath/union.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/lib/xpath/union.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/lib/xpath/union.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/lib/xpath/union.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/xpath-0.1.4/lib/xpath/union.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/lib/xpath/union.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/lib/xpath/union.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/lib/xpath/union.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/lib/xpath/union.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/xpath-0.1.4/lib/xpath/union.rb
xpath-0.1.4 lib/xpath/union.rb