Class: RDF::Tabular::Format

Inherits:
Format
  • Object
show all
Defined in:
lib/rdf/tabular/format.rb

Overview

Tabular Data/CSV format specification.

Examples:

Obtaining a Tabular format class

RDF::Format.for(:tabular)        #=> RDF::Tabular::Format
RDF::Format.for(:csv)            #=> RDF::Tabular::Format
RDF::Format.for(:tsv)            #=> RDF::Tabular::Format
RDF::Format.for("etc/foaf.csv")
RDF::Format.for("etc/foaf.tsv")
RDF::Format.for(file_name:      "etc/foaf.csv")
RDF::Format.for(file_name:      "etc/foaf.tsv")
RDF::Format.for(file_extension: "csv")
RDF::Format.for(file_extension: "tsv")
RDF::Format.for(content_type:   "text/csv")
RDF::Format.for(content_type:   "text/tab-separated-values")
RDF::Format.for(content_type:   "application/csvm+json")

Obtaining serialization format MIME types

RDF::Format.content_types      #=> {"text/csv" => [RDF::Tabular::Format]}

Obtaining serialization format file extension mappings

RDF::Format.file_extensions    #=> {:csv => "text/csv"}

See Also:

Class Method Summary collapse

Class Method Details

.detect(sample) ⇒ Boolean

Sample detection to see if it matches JSON-LD

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.

Parameters:

  • sample (String)

    Beginning several bytes (~ 1K) of input.

Returns:

  • (Boolean)


46
47
48
# File 'lib/rdf/tabular/format.rb', line 46

def self.detect(sample)
  !!sample.match(/^(?:(?:\w )+,(?:\w ))$/)
end