Class: RDF::N3::Algebra::Log::Content

Inherits:
ResourceOperator
  • Object
show all
Defined in:
lib/rdf/n3/algebra/log/content.rb

Overview

This connects a document and a string that represents it.

(Cwm knows how to go get a document in order to evaluate this.)

Note that the content-type of the information is not given and so must be known or guessed.

Constant Summary collapse

NAME =
:logContent
URI =
RDF::N3::Log.content

Instance Attribute Summary

Attributes included from Enumerable

#existentials, #universals

Instance Method Summary collapse

Methods inherited from ResourceOperator

#as_literal, #execute, #input_operand, #valid?

Methods included from Builtin

#each, #evaluate, #hash, #input_operand, #rank, #to_uri

Instance Method Details

#resolve(resource, position: :subject) ⇒ RDF::Term

Reads the subject into the object.

Returns nil if resource does not validate, given its position

Parameters:

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rdf/n3/algebra/log/content.rb', line 19

def resolve(resource, position: :subject)
  case position
  when :subject
    return nil unless resource.literal? || resource.uri?
    content = begin
      as_literal(RDF::Util::File.open_file(resource) {|f| f.read})
    rescue IOError
      nil
    end
  when :object
    return nil unless resource.literal? || resource.variable?
    resource
  end
end