Sha256: f1c6ec65b9c944dbd0780ec1b0e60972060c2a5e5e3c8cd66c1e0c1c5302d79c

Contents?: true

Size: 989 Bytes

Versions: 4

Compression:

Stored size: 989 Bytes

Contents

module RDF::N3::Algebra::Log
  ##
  # 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.
  class Content < RDF::N3::Algebra::ResourceOperator
    NAME = :logContent
    URI = RDF::N3::Log.content

    ##
    # Reads the subject into the object.
    #
    # Returns nil if resource does not validate, given its position
    #
    # @param [RDF::N3::List] resource
    # @return [RDF::Term]
    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdf-n3-3.3.0 lib/rdf/n3/algebra/log/content.rb
rdf-n3-3.2.1 lib/rdf/n3/algebra/log/content.rb
rdf-n3-3.2.0 lib/rdf/n3/algebra/log/content.rb
rdf-n3-3.1.2 lib/rdf/n3/algebra/log/content.rb