Class: RDF::Vocabulary
- Inherits:
-
Object
- Object
- RDF::Vocabulary
- Extended by:
- Enumerable
- Defined in:
- lib/rdf/vocab.rb
Overview
A Vocabulary represents an RDFS or OWL vocabulary.
Vocabularies:
The following vocabularies are pre-defined for your convenience:
- RDF - Resource Description Framework (RDF)
- CC - Creative Commons (CC)
- CERT - W3 Authentication Certificate (CERT)
- DC - Dublin Core (DC)
- DC11 - Dublin Core 1.1 (DC11) deprecated
- DOAP - Description of a Project (DOAP)
- EXIF - Exchangeable Image File Format (EXIF)
- FOAF - Friend of a Friend (FOAF)
- GEO - WGS84 Geo Positioning (GEO)
- HTTP - Hypertext Transfer Protocol (HTTP)
- OWL - Web Ontology Language (OWL)
- RDFS - RDF Schema (RDFS)
- RSA - W3 RSA Keys (RSA)
- RSS - RDF Site Summary (RSS)
- SIOC - Semantically-Interlinked Online Communities (SIOC)
- SKOS - Simple Knowledge Organization System (SKOS)
- WOT - Web of Trust (WOT)
- XHTML - Extensible HyperText Markup Language (XHTML)
- XSD - XML Schema (XSD)
Direct Known Subclasses
CC, CERT, DC, DC11, DOAP, EXIF, FOAF, GEO, HTTP, OWL, RDFS, RSA, RSS, SIOC, SIOC::Types, SKOS, WOT, XHTML, XSD
Class Method Summary (collapse)
-
+ (RDF::URI) [](property)
Returns the URI for the term
propertyin this vocabulary. -
+ (Symbol) __prefix__
Returns a suggested CURIE/QName prefix for this vocabulary class.
-
+ (Enumerator) each {|klass| ... }
Enumerates known RDF vocabulary classes.
-
+ (String) inspect
Returns a developer-friendly representation of this vocabulary class.
- + (Object) method_missing(property, *args, &block) protected
-
+ property(property)
Defines a vocabulary term called
property. -
+ (String) to_s
Returns a string representation of this vocabulary class.
-
+ (RDF::URI) to_uri
Returns the base URI for this vocabulary class.
Instance Method Summary (collapse)
-
- (URI) [](property)
Returns the URI for the term
propertyin this vocabulary. -
- (Vocabulary) initialize(uri)
constructor
A new instance of Vocabulary.
-
- (String) inspect
Returns a developer-friendly representation of this vocabulary.
- - (Object) method_missing(property, *args, &block) protected
-
- (String) to_s
Returns a string representation of this vocabulary.
-
- (URI) to_uri
Returns the base URI for this vocabulary.
Constructor Details
- (Vocabulary) initialize(uri)
A new instance of Vocabulary
136 137 138 139 140 141 |
# File 'lib/rdf/vocab.rb', line 136 def initialize(uri) @uri = case uri when RDF::URI then uri.to_s else RDF::URI.parse(uri.to_s) ? uri.to_s : nil end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(property, *args, &block) (protected)
201 202 203 204 205 206 207 |
# File 'lib/rdf/vocab.rb', line 201 def method_missing(property, *args, &block) if args.empty? self[property] else raise ArgumentError.new("wrong number of arguments (#{args.size} for 0)") end end |
Class Method Details
+ (RDF::URI) [](property)
Returns the URI for the term property in this vocabulary.
84 85 86 |
# File 'lib/rdf/vocab.rb', line 84 def self.[](property) RDF::URI.intern([to_s, property.to_s].join('')) end |
+ (Symbol) __prefix__
Returns a suggested CURIE/QName prefix for this vocabulary class.
127 128 129 |
# File 'lib/rdf/vocab.rb', line 127 def self.__prefix__ self.__name__.split('::').last.downcase.to_sym end |
+ (Enumerator) each {|klass| ... }
Enumerates known RDF vocabulary classes.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rdf/vocab.rb', line 57 def self.each(&block) if self.equal?(Vocabulary) # This is needed since all vocabulary classes are defined using # Ruby's autoloading facility, meaning that `@@subclasses` will be # empty until each subclass has been touched or require'd. RDF::VOCABS.each { |v| require "rdf/vocab/#{v}" unless v == :rdf } @@subclasses.each(&block) else # TODO: should enumerate vocabulary-specific defined properties. end end |
+ (String) inspect
Returns a developer-friendly representation of this vocabulary class.
108 109 110 111 112 113 114 |
# File 'lib/rdf/vocab.rb', line 108 def self.inspect if self == Vocabulary self.to_s else sprintf("%s(%s)", superclass.to_s, to_s) end end |
+ (Object) method_missing(property, *args, &block) (protected)
193 194 195 196 197 198 199 |
# File 'lib/rdf/vocab.rb', line 193 def self.method_missing(property, *args, &block) if args.empty? && @@uris.has_key?(self) self[property] else super end end |
+ property(property)
This method returns an undefined value.
Defines a vocabulary term called property.
74 75 76 77 |
# File 'lib/rdf/vocab.rb', line 74 def self.property(property) = class << self; self; end .send(:define_method, property) { self[property] } # class method end |
+ (String) to_s
Returns a string representation of this vocabulary class.
100 101 102 |
# File 'lib/rdf/vocab.rb', line 100 def self.to_s @@uris.has_key?(self) ? @@uris[self].to_s : super end |
+ (RDF::URI) to_uri
Returns the base URI for this vocabulary class.
92 93 94 |
# File 'lib/rdf/vocab.rb', line 92 def self.to_uri RDF::URI.intern(to_s) end |
Instance Method Details
- (URI) [](property)
Returns the URI for the term property in this vocabulary.
148 149 150 |
# File 'lib/rdf/vocab.rb', line 148 def [](property) RDF::URI.intern([to_s, property.to_s].join('')) end |
- (String) inspect
Returns a developer-friendly representation of this vocabulary.
172 173 174 |
# File 'lib/rdf/vocab.rb', line 172 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, to_s) end |
- (String) to_s
Returns a string representation of this vocabulary.
164 165 166 |
# File 'lib/rdf/vocab.rb', line 164 def to_s @uri.to_s end |
- (URI) to_uri
Returns the base URI for this vocabulary.
156 157 158 |
# File 'lib/rdf/vocab.rb', line 156 def to_uri RDF::URI.intern(to_s) end |