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.



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

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

Instance Attribute Details

#delegate ⇒ Object (readonly)

Returns the value of attribute delegate.



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

def delegate
  @delegate
end

#test ⇒ Object (readonly)

Returns the value of attribute test.



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

def test
  @test
end

Instance Method Details

#evaluate(program, uris, context) ⇒ Object



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

def evaluate program, uris, context
  entries = delegate.evaluate program, uris, context
  entries.select do |uri|
    Array(test.evaluate(program, uri, context)).any? do |x|
      x
    end
  end
end