Class: RDF::NQuads::Format
Overview
N-Quads format specification.
Class Method Summary (collapse)
-
+ (Boolean) detect(sample)
Sample detection to see if it matches N-Quads (or N-Triples).
Methods inherited from Format
content_encoding, content_type, content_types, each, file_extensions, for, reader, require, to_sym, writer
Class Method Details
+ (Boolean) detect(sample)
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.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rdf/nquads.rb', line 37 def self.detect(sample) !!sample.match(%r( (?:\s*(?:<[^>]*>) | (?:_:\w+)) # Subject (?:\s*<[^>]*>) # Predicate \s* (?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"]*"(?:^^|@\S+)?)) # Object (?:\s*<[^>]*>)? # Optional context \s*\. )mx) && ( !sample.match(%r(@(base|prefix|keywords))) # Not Turtle/N3 ) end |