Class: RDF::Repository
- Inherits:
-
Object
- Object
- RDF::Repository
- Includes:
- Countable, Durable, Enumerable, Mutable, Queryable
- Defined in:
- lib/rdf/repository.rb
Overview
An RDF repository.
Defined Under Namespace
Modules: Implementation
Instance Attribute Summary collapse
-
#options ⇒ Hash{Symbol => Object}
readonly
Returns the options passed to this repository when it was constructed.
-
#title ⇒ String
readonly
Returns the title of this repository.
-
#uri ⇒ URI
(also: #url)
readonly
Returns the URI of this repository.
Class Method Summary collapse
-
.load(filenames, options = {}) {|repository| ... } ⇒ void
Loads one or more RDF files into a new transient in-memory repository.
Instance Method Summary collapse
-
#initialize(options = {}) {|repository| ... } ⇒ Repository
constructor
Initializes this repository instance.
-
#inspect ⇒ String
Returns a developer-friendly representation of this object.
-
#inspect! ⇒ void
Outputs a developer-friendly representation of this object to ‘stderr`.
-
#transaction(context = nil) {|tx| ... } ⇒ void
(also: #transact)
Executes the given block in a transaction.
Methods included from Durable
Methods included from Util::Aliasing::LateBound
Methods included from Mutable
#<<, #clear, #delete, #immutable?, #insert, #load, #mutable?, #update
Methods included from Writable
Methods included from Readable
Methods included from Queryable
#first, #first_literal, #first_object, #first_predicate, #first_subject, #first_value, #query
Methods included from Enumerable
#contexts, #dump, #each_context, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_triple, #enum_context, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_triple, #has_context?, #has_object?, #has_predicate?, #has_quad?, #has_statement?, #has_subject?, #has_triple?, #objects, #predicates, #quads, #statements, #subjects, #supports?, #to_a, #to_hash, #to_set, #triples
Methods included from Countable
Constructor Details
#initialize(options = {}) {|repository| ... } ⇒ Repository
Initializes this repository instance.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/rdf/repository.rb', line 101 def initialize( = {}, &block) @options = .dup @uri = @options.delete(:uri) @title = @options.delete(:title) # Provide a default in-memory implementation: send(:extend, Implementation) if self.class.equal?(RDF::Repository) if block_given? case block.arity when 1 then block.call(self) else instance_eval(&block) end end end |
Instance Attribute Details
#options ⇒ Hash{Symbol => Object} (readonly)
Returns the options passed to this repository when it was constructed.
54 55 56 |
# File 'lib/rdf/repository.rb', line 54 def @options end |
#title ⇒ String (readonly)
Returns the title of this repository.
67 68 69 |
# File 'lib/rdf/repository.rb', line 67 def title @title end |
Class Method Details
.load(filenames, options = {}) {|repository| ... } ⇒ void
This method returns an undefined value.
Loads one or more RDF files into a new transient in-memory repository.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rdf/repository.rb', line 78 def self.load(filenames, = {}, &block) self.new() do |repository| [filenames].flatten.each do |filename| repository.load(filename, ) end if block_given? case block.arity when 1 then block.call(repository) else repository.instance_eval(&block) end end end end |
Instance Method Details
#inspect ⇒ String
Returns a developer-friendly representation of this object.
121 122 123 |
# File 'lib/rdf/repository.rb', line 121 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, uri.to_s) end |
#inspect! ⇒ void
This method returns an undefined value.
Outputs a developer-friendly representation of this object to ‘stderr`.
130 131 132 133 |
# File 'lib/rdf/repository.rb', line 130 def inspect! each_statement { |statement| statement.inspect! } nil end |
#transaction(context = nil) {|tx| ... } ⇒ void Also known as: transact
This method returns an undefined value.
Executes the given block in a transaction.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/rdf/repository.rb', line 150 def transaction(context = nil, &block) tx = begin_transaction(context) begin case block.arity when 1 then block.call(tx) else tx.instance_eval(&block) end rescue => error rollback_transaction(tx) raise error end commit_transaction(tx) self end |