Class: RDF::N3::Repository
- Inherits:
-
Repository
- Object
- Dataset
- Repository
- RDF::N3::Repository
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb
Overview
Sub-class of RDF::Repository which allows for native lists in different positions.
Constant Summary collapse
- DEFAULT_GRAPH =
false
Constants inherited from Repository
Constants inherited from Dataset
Instance Attribute Summary
Attributes inherited from Repository
Attributes included from Enumerable
Instance Method Summary collapse
- #apply_changeset(changeset) ⇒ Object
-
#each_expanded_statement {|RDF::Statement| ... } ⇒ Object
Projects statements with lists expanded to first/rest chains.
-
#expanded_statements ⇒ Array<RDF::Statement>
Returns the expanded statements for this repository.
-
#initialize(uri: nil, title: nil, **options) {|repository| ... } ⇒ Repository
constructor
Initializes this repository instance.
- #isolation_level ⇒ Object
-
#supports?(feature) ⇒ Boolean
Returns
true
if this respository supports the givenfeature
. -
#to_query ⇒ RDF::Query
Creates a query from the statements in this repository, turning blank nodes into non-distinguished variables.
Methods inherited from Repository
#delete_insert, load, #snapshot
Methods included from Transactable
#begin_transaction, #commit_transaction, #rollback_transaction, #transaction
Methods included from Mutable
#<<, add_entailment, #clear, #delete, #delete_insert, #delete_statements, #entail, #entail!, #immutable?, #insert, #load, #method_missing, #mutable?, #respond_to_missing?, #snapshot, #update
Methods included from Util::Aliasing::LateBound
Methods included from Util::Coercions
Methods included from Writable
#<<, #insert, #insert_graph, #insert_reader, #insert_statements, #writable?
Methods included from Readable
Methods inherited from Dataset
Methods included from Queryable
#concise_bounded_description, #first, #first_literal, #first_object, #first_predicate, #first_subject, #first_value, #lint, #query, #query_execute, #query_without_sparql, #to_sparql
Methods included from Durable
Methods included from Enumerable
add_entailment, #canonicalize, #canonicalize!, #dump, #each_object, #each_predicate, #each_quad, #each_subject, #each_term, #each_triple, #entail, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #graph?, #invalid?, #method_missing, #object?, #objects, #predicate?, #predicates, #project_graph, #quad?, #quads, #respond_to_missing?, #statement?, #statements, #subject?, #subjects, #term?, #terms, #to_a, #to_h, #to_set, #triple?, #triples, #valid?, #validate!
Methods included from Isomorphic
#bijection_to, #isomorphic_with?
Methods included from Countable
Constructor Details
#initialize(uri: nil, title: nil, **options) {|repository| ... } ⇒ Repository
Initializes this repository instance.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb', line 22 def initialize(uri: nil, title: nil, **, &block) @data = .delete(:data) || {} super do if block_given? case block.arity when 1 then block.call(self) else instance_eval(&block) end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Mutable
Instance Method Details
#apply_changeset(changeset) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb', line 155 def apply_changeset(changeset) data = @data changeset.deletes.each do |del| if del.constant? data = delete_from(data, del) else # we need this condition to handle wildcard statements query_pattern(del) { |stmt| data = delete_from(data, stmt) } end end changeset.inserts.each { |ins| data = insert_to(data, ins) } @data = data end |
#each_expanded_statement {|RDF::Statement| ... } ⇒ Object
Projects statements with lists expanded to first/rest chains
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb', line 128 def (&block) if block_given? each_statement do |st| if st.subject.list? st.subject.each_statement(&block) st.subject = st.subject.subject end if st.object.list? st.object.each_statement(&block) st.object = st.object.subject end block.call(st) end end enum_for(:each_expanded_statement) unless block_given? end |
#expanded_statements ⇒ Array<RDF::Statement>
Returns the expanded statements for this repository
149 150 151 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb', line 149 def .to_a end |
#isolation_level ⇒ Object
171 172 173 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb', line 171 def isolation_level :serializable end |
#supports?(feature) ⇒ Boolean
Returns true
if this respository supports the given feature
.
This repository supports list_terms.
38 39 40 41 42 43 44 45 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb', line 38 def supports?(feature) case feature.to_sym when :list_terms then true when :rdfstar then true when :snapshots then false else super end end |
#to_query ⇒ RDF::Query
Creates a query from the statements in this repository, turning blank nodes into non-distinguished variables. This can be used to determine if this repository is logically a subset of another repository.
51 52 53 54 55 56 57 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-n3-a6ef81a7e1ce/lib/rdf/n3/repository.rb', line 51 def to_query RDF::Query.new do |query| each do |statement| query.pattern RDF::Query::Pattern.from(statement, ndvars: true) end end end |