Sha256: 201e7a9d4526b362567e78bb78b81d19f333580183271aad01a825a0bcaa711a

Contents?: true

Size: 932 Bytes

Versions: 4

Compression:

Stored size: 932 Bytes

Contents

module Spread2RDF
  module Mapping
    module ResourceCreation

      def create_resource
        case schema.resource_creation_mode
          when :bnode                   then RDF::Node.new
          when :from_column_with_suffix then resource_from_suffix
          when :from_column             then resource_from_full_uri
          else raise 'unknown resource creation mode'
        end
      end

      def resource_from_full_uri
        RDF::URI.new(resource_creation_value, validate: true)
      end
      private :resource_from_full_uri

      def resource_from_suffix
        namespace = schema.resource_creation_namespace
        suffix = Mapping::Cell::Default.uri_normalization(resource_creation_value)
        #puts "creating resource " + RDF::URI.new("#{namespace}#{suffix}" )
        RDF::URI.new("#{namespace}#{suffix}")
      end
      private :resource_from_suffix

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spread2rdf-0.1.7 lib/spread2rdf/mapping/resource_creation.rb
spread2rdf-0.1.6 lib/spread2rdf/mapping/resource_creation.rb
spread2rdf-0.1.5 lib/spread2rdf/mapping/resource_creation.rb
spread2rdf-0.1.4 lib/spread2rdf/mapping/resource_creation.rb