Class: RDF::RDFa::Format

Inherits:
Format show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-fb11c7e2d467/lib/rdf/rdfa/format.rb

Overview

RDFa format specification.

Examples:

Obtaining an RDFa format class

RDF::Format.for(:rdfa)     #=> RDF::RDFa::Format
RDF::Format.for("etc/doap.html")
RDF::Format.for(file_name:      "etc/doap.html")
RDF::Format.for(file_extension: "html")
RDF::Format.for(content_type:   "text/html")
RDF::Format.for(content_type:   "application/xhtml+xml")

Obtaining serialization format MIME types

RDF::Format.content_types      #=> {"text/html" => [RDF::RDFa::Format]}

Obtaining serialization format file extension mappings

RDF::Format.file_extensions    #=> {xhtml: "application/xhtml+xml"}

See Also:

Class Method Summary collapse

Methods inherited from Format

accept_type, accept_types, cli_commands, content_encoding, content_type, content_types, each, file_extension, file_extensions, for, name, reader, reader_symbols, reader_types, require, to_sym, uri, uris, writer, writer_symbols, writer_types

Class Method Details

.detect(sample) ⇒ Boolean

Sample detection to see if it matches RDFa (not RDF/XML or Microdata)

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)


38
39
40
41
42
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-fb11c7e2d467/lib/rdf/rdfa/format.rb', line 38

def self.detect(sample)
  (sample.match(/<[^>]*(about|resource|prefix|typeof|property|vocab)\s*="[^>]*>/m) ||
   sample.match(/<[^>]*DOCTYPE\s+html[^>]*>.*xmlns:/im)
  ) && !sample.match(/<(\w+:)?(RDF)/)
end

.symbolsObject



44
45
46
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfa-fb11c7e2d467/lib/rdf/rdfa/format.rb', line 44

def self.symbols
  [:rdfa, :lite, :html, :xhtml, :svg]
end