Class: RDF::Microdata::Format

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

Overview

Microdata format specification.

Examples:

Obtaining a Microdata format class

RDF::Format.for(:microdata)         #=> RDF::Microdata::Format
RDF::Format.for("etc/foaf.html")
RDF::Format.for(:file_name      => "etc/foaf.html")
RDF::Format.for(file_extension: "html")
RDF::Format.for(:content_type   => "text/html")

Obtaining serialization format MIME types

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

See Also:

Class Method Summary collapse

Class Method Details

.detect(sample) ⇒ Boolean

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

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)


41
42
43
# File 'lib/rdf/microdata/format.rb', line 41

def self.detect(sample)
  !!sample.match(/<[^>]*(itemprop|itemtype|itemref|itemscope|itemid)[^>]*>/m)
end