Sha256: a6f1e2d60f9ce9a456819f23b676a945643d43e6663909240558001fe40440c5

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module RdfContext
  # Common super-class for things that are RDF Resources
  class Resource

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

    ##
    # Returns `false`, overridden in Literal
    #
    # @return [Boolean]
    def literal?
      false
    end

    ##
    # Returns `false`, overridden in URIref
    #
    # @return [Boolean]
    def uri?
      false
    end

    ##
    # Returns `false`, overridden in BNode
    #
    # @return [Boolean]
    def bnode?
      false
    end
    
    ##
    # Returns `false`, overridden in BNode
    #
    # @return [Boolean]
    def graph?
      false
    end
    
    # Parse a string to a resource, in NTriples format
    def self.parse(str)
      case str
      when /^_:/    then BNode.parse(str)
      when /^</     then URIRef.parse(str)
      when /^http:/ then URIRef.parse(str)
      when /^\"/    then Literal.parse(str)
      else               Literal.parse(str)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rdf_context-0.5.11 lib/rdf_context/resource.rb
rdf_context-0.5.10 lib/rdf_context/resource.rb