Class: Ldpath::TestSelector

Inherits:
Selector show all
Defined in:
lib/ldpath/tests.rb

Direct Known Subclasses

AndTest, IsTest, LanguageTest, NotTest, OrTest, TypeTest

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Selector

#loading

Constructor Details

#initialize(delegate, test) ⇒ TestSelector

Returns a new instance of TestSelector.



5
6
7
8
# File 'lib/ldpath/tests.rb', line 5

def initialize(delegate, test)
  @delegate = delegate
  @test = test
end

Instance Attribute Details

#delegateObject (readonly)

Returns the value of attribute delegate.



3
4
5
# File 'lib/ldpath/tests.rb', line 3

def delegate
  @delegate
end

#testObject (readonly)

Returns the value of attribute test.



3
4
5
# File 'lib/ldpath/tests.rb', line 3

def test
  @test
end

Instance Method Details

#evaluate(program, uris, context) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ldpath/tests.rb', line 10

def evaluate(program, uris, context)
  return to_enum(:evaluate, program, uris, context) unless block_given?

  entries = delegate.evaluate program, uris, context
  entries.select do |uri|
    result = enum_wrap(test.evaluate(program, uri, context)).any? do |x|
      x
    end
    yield uri if result
  end
end