File: union.rb

package info (click to toggle)
ruby-xpath 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 140 kB
  • sloc: ruby: 847; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 618 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module XPath
  class Union
    include Enumerable

    attr_reader :expressions
    alias_method :arguments, :expressions

    def initialize(*expressions)
      @expressions = expressions
    end

    def expression
      :union
    end

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

    def method_missing(*args) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
      XPath::Union.new(*arguments.map { |e| e.send(*args) })
    end

    def to_xpath(type = nil)
      Renderer.render(self, type)
    end
    alias_method :to_s, :to_xpath
  end
end