Module: RDF
- Defined in:
- lib/rdf.rb,
lib/rdf/cli.rb,
lib/rdf/util.rb,
lib/rdf/query.rb,
lib/rdf/format.rb,
lib/rdf/nquads.rb,
lib/rdf/reader.rb,
lib/rdf/writer.rb,
lib/rdf/version.rb,
lib/rdf/ntriples.rb,
lib/rdf/changeset.rb,
lib/rdf/model/uri.rb,
lib/rdf/util/file.rb,
lib/rdf/util/uuid.rb,
lib/rdf/vocab/owl.rb,
lib/rdf/vocab/xsd.rb,
lib/rdf/model/list.rb,
lib/rdf/model/node.rb,
lib/rdf/model/term.rb,
lib/rdf/repository.rb,
lib/rdf/util/cache.rb,
lib/rdf/vocab/rdfs.rb,
lib/rdf/vocab/rdfv.rb,
lib/rdf/vocabulary.rb,
lib/rdf/model/graph.rb,
lib/rdf/model/value.rb,
lib/rdf/transaction.rb,
lib/rdf/util/logger.rb,
lib/rdf/vocab/writer.rb,
lib/rdf/mixin/durable.rb,
lib/rdf/mixin/mutable.rb,
lib/rdf/model/dataset.rb,
lib/rdf/model/literal.rb,
lib/rdf/query/pattern.rb,
lib/rdf/util/aliasing.rb,
lib/rdf/mixin/readable.rb,
lib/rdf/mixin/writable.rb,
lib/rdf/model/resource.rb,
lib/rdf/util/coercions.rb,
lib/rdf/mixin/countable.rb,
lib/rdf/mixin/indexable.rb,
lib/rdf/mixin/queryable.rb,
lib/rdf/model/statement.rb,
lib/rdf/query/solutions.rb,
lib/rdf/mixin/enumerable.rb,
lib/rdf/mixin/type_check.rb,
lib/rdf/mixin/transactable.rb,
lib/rdf/model/literal/date.rb,
lib/rdf/model/literal/time.rb,
lib/rdf/model/literal/token.rb,
lib/rdf/model/literal/double.rb,
lib/rdf/model/literal/boolean.rb,
lib/rdf/model/literal/decimal.rb,
lib/rdf/model/literal/integer.rb,
lib/rdf/model/literal/numeric.rb,
lib/rdf/model/literal/datetime.rb,
lib/rdf/model/literal/temporal.rb,
lib/rdf/query/hash_pattern_normalizer.rb
Defined Under Namespace
Modules: Countable, Durable, Enumerable, Indexable, Mutable, NQuads, NTriples, Queryable, Readable, Resource, Term, Transactable, TypeCheck, Util, VERSION, Value, Writable Classes: CLI, Changeset, Dataset, Format, FormatError, Graph, List, Literal, Node, OWL, Query, RDFS, RDFV, Reader, ReaderError, Repository, Statement, StrictVocabulary, Transaction, URI, Vocabulary, Writer, WriterError, XSD
Constant Summary collapse
- VOCABS =
{ owl: {uri: "http://www.w3.org/2002/07/owl#", class_name: "OWL"}, rdfs: {uri: "http://www.w3.org/2000/01/rdf-schema#", class_name: "RDFS"}, rdfv: {uri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", class_name: "RDFV"}, xsd: {uri: "http://www.w3.org/2001/XMLSchema#", class_name: "XSD"}, }
- RDF_N_REGEXP =
%r{_\d+}.freeze
- IRI =
RDF::IRI is a synonym for RDF::URI
URI
Class Method Summary collapse
- .[](property) ⇒ #to_s, URI
-
.config ⇒ Object
Configuration, used open for configuring constants used within the codebase.
-
.enum_for(method = :each_statement, *args) ⇒ RDF::Enumerable::Enumerator
(also: to_enum)
Return an enumerator over Statement defined for this vocabulary.
-
.Graph(**options, &block) ⇒ RDF::Graph
Alias for ‘RDF::Graph.new`.
- .List(*args) ⇒ Object
-
.Literal(literal, **options) ⇒ RDF::Literal
Alias for ‘RDF::Literal.new`.
-
.method_missing(property, *args, &block) ⇒ Object
Delegate other methods to RDF::RDFV.
-
.Node(*args) ⇒ RDF::Node
Alias for ‘RDF::Node.new`.
-
.Resource(*args) ⇒ RDF::Resource
Alias for ‘RDF::Resource.new`.
-
.respond_to?(method, include_all = false) ⇒ Boolean
respond to module or RDFV.
- .Statement(*args, **options) ⇒ Object
-
.StrictVocabulary(uri) ⇒ Class
Alias for ‘RDF::StrictVocabulary.create`.
-
.URI(*args) ⇒ RDF::URI
Cast to a URI.
-
.Vocabulary(uri) ⇒ Class
Alias for ‘RDF::Vocabulary.create`.
Class Method Details
.[](property) ⇒ #to_s, URI
235 236 237 |
# File 'lib/rdf.rb', line 235 def self.[](property) property.to_s.match?(%r{_\d+}) ? RDF::URI("#{to_uri}#{property}") : RDF::RDFV[property] end |
.config ⇒ Object
cache configurations must be set before initial use, when the caches are allocated.
Configuration, used open for configuring constants used within the codebase.
Defaults:
* `cache_size`: -1
* `uri_cache_size`: `cache_size`
* `node_cache_size`: `cache_size`
98 99 100 |
# File 'lib/rdf.rb', line 98 def self.config @config ||= OpenStruct.new(cache_size: -1, uri_cache_size: nil, node_cache_size: nil) end |
.enum_for(method = :each_statement, *args) ⇒ RDF::Enumerable::Enumerator Also known as: to_enum
Return an enumerator over Statement defined for this vocabulary.
243 244 245 246 247 248 |
# File 'lib/rdf.rb', line 243 def self.enum_for(method = :each_statement, *args) # Ensure that enumerators are, themselves, queryable Enumerable::Enumerator.new do |yielder| RDF::RDFV.send(method, *args) {|*y| yielder << (y.length > 1 ? y : y.first)} end end |
.Graph(**options, &block) ⇒ RDF::Graph
Alias for ‘RDF::Graph.new`.
153 154 155 |
# File 'lib/rdf.rb', line 153 def self.Graph(**, &block) Graph.new(**, &block) end |
.List ⇒ RDF::URI .List(*args) ⇒ RDF::List .List(array) ⇒ RDF::List .List(list) ⇒ RDF::List
172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/rdf.rb', line 172 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(literal, **options) ⇒ RDF::Literal
Alias for ‘RDF::Literal.new`.
141 142 143 144 145 146 |
# File 'lib/rdf.rb', line 141 def self.Literal(literal, **) case literal when RDF::Literal then literal else Literal.new(literal, **) end end |
.method_missing(property, *args, &block) ⇒ Object
Delegate other methods to RDF::RDFV
263 264 265 266 267 268 269 270 |
# File 'lib/rdf.rb', line 263 def self.method_missing(property, *args, &block) if args.empty? # Special-case rdf:_n for all integers RDF_N_REGEXP.match?(property) ? RDF::URI("#{to_uri}#{property}") : RDF::RDFV.send(property) else super end end |
.Node(*args) ⇒ RDF::Node
Alias for ‘RDF::Node.new`.
116 117 118 |
# File 'lib/rdf.rb', line 116 def self.Node(*args) Node.new(*args) end |
.Resource(*args) ⇒ RDF::Resource
Alias for ‘RDF::Resource.new`.
107 108 109 |
# File 'lib/rdf.rb', line 107 def self.Resource(*args) Resource.new(*args) end |
.respond_to?(method, include_all = false) ⇒ Boolean
respond to module or RDFV
255 256 257 |
# File 'lib/rdf.rb', line 255 def self.respond_to?(method, include_all = false) super || RDF::RDFV.respond_to?(method, include_all) end |
.Statement ⇒ RDF::URI .Statement(**options) ⇒ RDF::Statement .Statement(subject, predicate, object, **options) ⇒ RDF::Statement
206 207 208 209 210 211 212 |
# File 'lib/rdf.rb', line 206 def self.Statement(*args, **) if args.empty? && .empty? RDF[:Statement] else Statement.new(*args, **) end end |
.StrictVocabulary(uri) ⇒ Class
Alias for ‘RDF::StrictVocabulary.create`.
228 229 230 |
# File 'lib/rdf.rb', line 228 def self.StrictVocabulary(uri) StrictVocabulary.create(uri) end |
.URI(*args) ⇒ RDF::URI
Cast to a URI. If already a URI, return the passed argument.
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/rdf.rb', line 125 def self.URI(*args) if args.first.respond_to?(:to_uri) args.first.to_uri elsif args.first.is_a?(Hash) URI.new(**args.first) else opts = args.last.is_a?(Hash) ? args.pop : {} URI.new(*args, **opts) end end |
.Vocabulary(uri) ⇒ Class
Alias for ‘RDF::Vocabulary.create`.
219 220 221 |
# File 'lib/rdf.rb', line 219 def self.Vocabulary(uri) Vocabulary.create(uri) end |