Class: XPath::Union

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/xpath/union.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*expressions) ⇒ Union

Returns a new instance of Union.



7
8
9
# File 'lib/xpath/union.rb', line 7

def initialize(*expressions)
  @expressions = expressions
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



23
24
25
# File 'lib/xpath/union.rb', line 23

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

Instance Attribute Details

#expressionsObject (readonly)

Returns the value of attribute expressions.



5
6
7
# File 'lib/xpath/union.rb', line 5

def expressions
  @expressions
end

Instance Method Details

#each(&block) ⇒ Object



11
12
13
# File 'lib/xpath/union.rb', line 11

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

#to_xpath(predicate = nil) ⇒ Object



15
16
17
# File 'lib/xpath/union.rb', line 15

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

#to_xpathsObject



19
20
21
# File 'lib/xpath/union.rb', line 19

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