Module: RDF::Writable

Extended by:
Util::Aliasing::LateBound
Includes:
Util::Coercions
Included in:
Mutable, Writer
Defined in:
lib/rdf/mixin/writable.rb

Overview

Classes that include this module must implement the methods ‘#insert_statement`.

See Also:

Instance Method Summary collapse

Methods included from Util::Aliasing::LateBound

alias_method

Instance Method Details

#<<(data) ⇒ self

Inserts RDF data into ‘self`.

Parameters:

Returns:

  • (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.

Overloads:

  • #insert(*statements) ⇒ self

    Parameters:

    Returns:

    • (self)

    Raises:

    • (ArgumentError)

      on an attempt to insert an embedded statement when it is not supported

  • #insert(statements) ⇒ self

    Parameters:

    Returns:

    • (self)

    Raises:

    • (ArgumentError)

      on an attempt to insert an embedded statement when it is not supported



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.

Returns:

  • (Boolean)

    ‘true` or `false`

See Also:



17
18
19
# File 'lib/rdf/mixin/writable.rb', line 17

def writable?
  !frozen?
end