Sha256: e34948ff9a5b2735983d6cc2132f1c99e1ba1cc398e675002620eeea03f7f812

Contents?: true

Size: 608 Bytes

Versions: 7

Compression:

Stored size: 608 Bytes

Contents

module RDF
  ##
  # An RDF resource.
  #
  # @abstract
  class Resource < Value
    ##
    # Instantiates an {RDF::Node} or an {RDF::URI}, depending on the given
    # argument.
    #
    # @return [RDF::Resource]
    def self.new(*args, &block)
      if self == Resource
        case arg = args.shift
          when /^_:(.*)$/ then Node.new($1, *args, &block)
          else URI.new(arg, *args, &block)
        end
      else
        super
      end
    end

    ##
    # Returns `true` to indicate that this value is a resource.
    #
    # @return [Boolean]
    def resource?
      true
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rdf-0.1.10 lib/rdf/model/resource.rb
rdf-0.1.9 lib/rdf/model/resource.rb
rdf-0.1.8 lib/rdf/model/resource.rb
rdf-0.1.7 lib/rdf/model/resource.rb
rdf-0.1.6.1 lib/rdf/model/resource.rb
rdf-0.1.6 lib/rdf/model/resource.rb
rdf-0.1.5 lib/rdf/model/resource.rb