Class: RDF::Dataset
- Inherits:
-
Object
- Object
- RDF::Dataset
- Includes:
- Durable, Enumerable, Queryable
- Defined in:
- lib/rdf/model/dataset.rb
Overview
An RDF Dataset
Datasets are immutable by default. Repository provides an interface for mutable Datasets.
A Dataset functions as an a set of named RDF graphs with a default graph. It implements Enumerable and Queryable over the whole set; if no specific graph name is queried, enumerating and querying takes place over the intersection of all the graphs in the Dataset.
The default graph is named with a constant ‘DEFAULT_GRAPH`.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_GRAPH =
false
- ISOLATION_LEVELS =
[ :read_uncommitted, :read_committed, :repeatable_read, :snapshot, :serializable ].freeze
Instance Method Summary collapse
- #durable? ⇒ Boolean
- #each ⇒ Object
-
#initialize(statements: [], **options) {|dataset| ... } ⇒ Dataset
constructor
A new instance of Dataset.
-
#inspect ⇒ String
Returns a developer-friendly representation of this object.
-
#inspect! ⇒ void
Outputs a developer-friendly representation of this object to ‘stderr`.
-
#isolation_level ⇒ Symbol
‘:snapshot`, or `:serializable`.
- #supports?(feature) ⇒ Boolean
Methods included from Queryable
#enum_for, #first, #first_literal, #first_object, #first_predicate, #first_subject, #first_value, #query
Methods included from Durable
Methods included from Util::Aliasing::LateBound
Methods included from Enumerable
#canonicalize, #canonicalize!, #dump, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_term, #each_triple, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #graph?, #graph_names, #invalid?, #object?, #objects, #predicate?, #predicates, #project_graph, #quad?, #quads, #statement?, #statements, #subject?, #subjects, #term?, #terms, #to_a, #to_h, #to_set, #triple?, #triples, #valid?, #validate!
Methods included from Countable
Constructor Details
#initialize(statements: [], **options) {|dataset| ... } ⇒ Dataset
Returns a new instance of Dataset.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rdf/model/dataset.rb', line 40 def initialize(statements: [], **, &block) @statements = statements.map do |s| s = s.dup s.graph_name ||= DEFAULT_GRAPH s.freeze end.freeze if block_given? case block.arity when 1 then yield self else instance_eval(&block) end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Enumerable
Instance Method Details
#durable? ⇒ Boolean
58 59 60 |
# File 'lib/rdf/model/dataset.rb', line 58 def durable? false end |
#each ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rdf/model/dataset.rb', line 65 def each @statements.each do |st| if st.graph_name.equal?(DEFAULT_GRAPH) st = st.dup st.graph_name = nil end yield st end self end |
#inspect ⇒ String
Returns a developer-friendly representation of this object.
81 82 83 |
# File 'lib/rdf/model/dataset.rb', line 81 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, count.to_s) end |
#inspect! ⇒ void
This method returns an undefined value.
Outputs a developer-friendly representation of this object to ‘stderr`.
90 91 92 93 |
# File 'lib/rdf/model/dataset.rb', line 90 def inspect! each_statement { |statement| statement.inspect! } nil end |
#isolation_level ⇒ Symbol
‘:snapshot`, or `:serializable`.
99 100 101 |
# File 'lib/rdf/model/dataset.rb', line 99 def isolation_level :read_committed end |
#supports?(feature) ⇒ Boolean
106 107 108 109 110 |
# File 'lib/rdf/model/dataset.rb', line 106 def supports?(feature) # FIXME: quoted triples are now deprecated return true if %i(graph_name quoted_triples rdf_full).include?(feature) super end |