Module: RDF::Writable
- Extended by:
- Util::Aliasing::LateBound
- Includes:
- Util::Coercions
- Defined in:
- lib/rdf/mixin/writable.rb
Overview
Classes that include this module must implement the methods ‘#insert_statement`.
Instance Method Summary collapse
-
#<<(data) ⇒ self
Inserts RDF data into ‘self`.
-
#insert(*statements) ⇒ Object
(also: #insert!)
Inserts RDF statements into ‘self`.
-
#writable? ⇒ Boolean
Returns ‘true` if `self` is writable.
Methods included from Util::Aliasing::LateBound
Instance Method Details
#<<(data) ⇒ self
Inserts RDF data into ‘self`.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rdf/mixin/writable.rb', line 26 def <<(data) case data when RDF::Reader insert_reader(data) when RDF::Graph insert_graph(data) when RDF::Enumerable insert_statements(data) when RDF::Statement insert_statement(data) else case when data.respond_to?(:to_rdf) && !data.equal?(rdf = data.to_rdf) self << rdf else insert_statement(Statement.from(data)) end end return self end |
#insert(*statements) ⇒ self #insert(statements) ⇒ self Also known as: insert!
Note:
using splat argument syntax with excessive arguments provided
Inserts RDF statements into ‘self`.
significantly affects performance. Use Enumerator form for large numbers of statements.
63 64 65 66 67 |
# File 'lib/rdf/mixin/writable.rb', line 63 def insert(*statements) coerce_statements(statements) { |value| insert_statements value } return self end |
#writable? ⇒ Boolean
Returns ‘true` if `self` is writable.
17 18 19 |
# File 'lib/rdf/mixin/writable.rb', line 17 def writable? !frozen? end |