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.



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

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

  super
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



229
230
231
# File 'lib/ldpath/selectors.rb', line 229

def identifier
  @identifier
end

#tapObject (readonly)

Returns the value of attribute tap.



229
230
231
# File 'lib/ldpath/selectors.rb', line 229

def tap
  @tap
end

Instance Method Details

#evaluate(program, uris, context) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/ldpath/selectors.rb', line 238

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



251
252
253
# File 'lib/ldpath/selectors.rb', line 251

def evaluate_one(uri, _context)
  uri
end