class RDF::NQuads::Format
N-Quads format specification.
@example Obtaining an NQuads format class
RDF::Format.for(:nquads) #=> RDF::NQuads::Format RDF::Format.for("etc/doap.nq") RDF::Format.for(file_name: "etc/doap.nq") RDF::Format.for(file_extension: "nq") RDF::Format.for(content_type: "application/n-quads")
@see www.w3.org/TR/n-quads/ @since 0.4.0
Public Class Methods
detect(sample)
click to toggle source
Sample detection to see if it matches N-Quads (or N-Triples)
Use a text sample to detect the format of an input file. Sub-classes implement a matcher sufficient to detect probably format matches, including disambiguating between other similar formats.
@param [String] sample Beginning several bytes (about 1K) of input. @return [Boolean]
# File lib/rdf/nquads.rb, line 37 def self.detect(sample) !!sample.match(%r( (?:\s*(?:<[^>]*>) | (?:_:\w+)) # Subject \s* (?:\s*<[^>]*>) # Predicate \s* (?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"\n]*"(?:^^|@\S+)?)) # Object \s* (?:\s*(?:<[^>]*>) | (?:_:\w+)) # Graph Name \s*\. )x) && !( sample.match(%r(@(base|prefix|keywords)|\{)) || # Not Turtle/N3/TriG sample.match(%r(<(html|rdf))i) # Not HTML or XML ) end
name()
click to toggle source
Human readable name for this format
# File lib/rdf/nquads.rb, line 54 def self.name; "N-Quads"; end