module RDF

Constants

IRI

A Uniform Resource Identifier (URI). Also compatible with International Resource Identifier (IRI)

@example Creating a URI reference (1)

uri = RDF::URI.new("http://rubygems.org/gems/rdf")

@example Creating a URI reference (2)

uri = RDF::URI.new(scheme: 'http', host: 'rubygems.org', path: '/gems/rdf')
  #=> RDF::URI.new("http://rubygems.org/gems/rdf")

@example Creating an interned URI reference

uri = RDF::URI.intern("http://rubygems.org/gems/rdf")

@example Getting the string representation of a URI

uri.to_s #=> "http://rubygems.org/gems/rdf"

en.wikipedia.org/wiki/Internationalized_Resource_Identifier @see en.wikipedia.org/wiki/Uniform_Resource_Identifier @see www.ietf.org/rfc/rfc3986.txt @see www.ietf.org/rfc/rfc3987.txt @see addressable.rubyforge.org/

VOCABS

Public Class Methods

Graph(**options, &block) click to toggle source

Alias for `RDF::Graph.new`.

@param (see RDF::Graph#initialize) @return [RDF::Graph]

# File lib/rdf.rb, line 123
def self.Graph(**options, &block)
  Graph.new(options, &block)
end
List(*args) click to toggle source

@overload List()

@return [RDF::URI] returns the IRI for `rdf:List`

@overload List(*args)

@param (see RDF::List#[])
@return [RDF::List]

@overload List(array)

@param [Array] array
@return [RDF::List]

@overload List(list)

@param [RDF::List] list
@return [RDF::List] returns itself
# File lib/rdf.rb, line 142
def self.List(*args)
  case
  when args.empty?
    RDF[:List]
  when args.length == 1 && args.first.is_a?(RDF::List)
    args.first
  when args.length == 1 && args.first.is_a?(Array)
    List[*args.first]
  else
    List[*args]
  end
end
Literal(*args, &block) click to toggle source

Alias for `RDF::Literal.new`.

@param (see RDF::Literal#initialize) @return [RDF::Literal]

# File lib/rdf.rb, line 111
def self.Literal(*args, &block)
  case literal = args.first
    when RDF::Literal then literal
    else Literal.new(*args, &block)
  end
end
Node(*args, &block) click to toggle source

Alias for `RDF::Node.new`.

@param (see RDF::Node#initialize) @return [RDF::Node]

# File lib/rdf.rb, line 87
def self.Node(*args, &block)
  Node.new(*args, &block)
end
Resource(*args, &block) click to toggle source

Alias for `RDF::Resource.new`.

@param (see RDF::Resource#initialize) @return [RDF::Resource]

# File lib/rdf.rb, line 78
def self.Resource(*args, &block)
  Resource.new(*args, &block)
end
Statement(*args) click to toggle source

@overload Statement()

@return [RDF::URI] returns the IRI for `rdf:Statement`

@overload Statement(options = {})

@param  [Hash{Symbol => Object}] options
@option options [RDF::Resource]  :subject   (nil)
@option options [RDF::URI]       :predicate (nil)
@option options [RDF::Term]      :object    (nil)
@option options [RDF::Resource]  :graph_name   (nil)
  Note, a graph_name MUST be an IRI or BNode.
@return [RDF::Statement]

@overload Statement(subject, predicate, object, options = {})

@param  [RDF::Resource]          subject
@param  [RDF::URI]               predicate
@param  [RDF::Term]              object
@param  [Hash{Symbol => Object}] options
@option options [RDF::Resource]  :graph_name   (nil)
@return [RDF::Statement]
# File lib/rdf.rb, line 176
def self.Statement(*args)
  if args.empty?
    RDF[:Statement]
  else
    Statement.new(*args)
  end
end
StrictVocabulary(prefix) click to toggle source

Alias for `RDF::StrictVocabulary.create`.

@param (see RDF::Vocabulary#initialize) @return [Class]

# File lib/rdf.rb, line 198
def self.StrictVocabulary(prefix)
  StrictVocabulary.create(prefix)
end
URI(*args, &block) click to toggle source

Alias for `RDF::URI.new`.

@param (see RDF::URI#initialize) @return [RDF::URI]

# File lib/rdf.rb, line 96
def self.URI(*args, &block)
  case uri = args.first
    when RDF::URI then uri
    else case
      when uri.respond_to?(:to_uri) then uri.to_uri
      else URI.new(*args, &block)
    end
  end
end
Vocabulary(uri) click to toggle source

Alias for `RDF::Vocabulary.create`.

@param (see RDF::Vocabulary#initialize) @return [Class]

# File lib/rdf.rb, line 189
def self.Vocabulary(uri)
  Vocabulary.create(uri)
end
[](property) click to toggle source

@return [#to_s] property @return [URI]

# File lib/rdf.rb, line 205
def self.[](property)
  property.to_s =~ %r{_\d+} ? RDF::URI("#{to_uri}#{property}") : RDF::RDFV[property]
end
const_missing(constant) click to toggle source

Use ::const_missing instead of autoload to load most vocabularies so we can provide deprecation messages

Calls superclass method
# File lib/rdf.rb, line 61
def self.const_missing(constant)
  if VOCABS.include?(constant.to_s.downcase.to_sym)
    require "rdf/vocab/#{constant.to_s.downcase}"
    const_get(constant)
  else
    super
  end
end
method_missing(property, *args, &block) click to toggle source

Delegate other methods to RDF::RDFV

Calls superclass method
# File lib/rdf.rb, line 217
def self.method_missing(property, *args, &block)
  if args.empty?
    # Special-case rdf:_n for all integers
    property.to_s =~ %r{_\d+} ? RDF::URI("#{to_uri}#{property}") : RDF::RDFV.send(property)
  else
    super
  end
end
respond_to?(method, include_all = false) click to toggle source

respond to module or RDFV

Calls superclass method
# File lib/rdf.rb, line 211
def self.respond_to?(method, include_all = false)
  super || RDF::RDFV.respond_to?(method, include_all)
end