Class: Ldpath::TapSelector

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Selector

#loading

Constructor Details

#initialize(identifier, tap) ⇒ TapSelector

Returns a new instance of TapSelector.



214
215
216
217
# File 'lib/ldpath/selectors.rb', line 214

def initialize(identifier, tap)
  @identifier = identifier
  @tap = tap
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



213
214
215
# File 'lib/ldpath/selectors.rb', line 213

def identifier
  @identifier
end

#tapObject (readonly)

Returns the value of attribute tap.



213
214
215
# File 'lib/ldpath/selectors.rb', line 213

def tap
  @tap
end

Instance Method Details

#evaluate(program, uris, context) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/ldpath/selectors.rb', line 219

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

  program.meta[identifier] = tap.evaluate(program, uris, context).map { |x| RDF::Literal.new(x.to_s).canonicalize.object }

  enum_wrap(uris).map do |uri|
    loading program, uri, context
    enum_flatten_one(evaluate_one(uri, context)).each do |x|
      yield x unless x.nil?
    end
  end
end

#evaluate_one(uri, _context) ⇒ Object



232
233
234
# File 'lib/ldpath/selectors.rb', line 232

def evaluate_one(uri, _context)
  uri
end