module RDF::Enumerable

An RDF statement enumeration mixin.

Classes that include this module must implement an ‘#each` method that yields {RDF::Statement RDF statements}.

@example Checking whether any statements exist

enumerable.empty?

@example Checking how many statements exist

enumerable.count

@example Checking whether a specific statement exists

enumerable.statement?(RDF::Statement(subject, predicate, object))
enumerable.triple?([subject, predicate, object])
enumerable.quad?([subject, predicate, object, graph_name])

@example Checking whether a specific value exists

enumerable.subject?(RDF::URI("https://rubygems.org/gems/rdf"))
enumerable.predicate?(RDF::RDFS.label)
enumerable.object?(RDF::Literal("A Ruby library for working with Resource Description Framework (RDF) data.", language: :en))
enumerable.graph?(RDF::URI("http://ar.to/#self"))

@example Enumerating all statements

enumerable.each_statement do |statement|
  puts statement.inspect
end

@example Enumerating all statements in the form of triples

enumerable.each_triple do |subject, predicate, object|
  puts [subject, predicate, object].inspect
end

@example Enumerating all statements in the form of quads

enumerable.each_quad do |subject, predicate, object, graph_name|
  puts [subject, predicate, object, graph_name].inspect
end

@example Enumerating all terms

enumerable.each_subject   { |term| puts term.inspect }
enumerable.each_predicate { |term| puts term.inspect }
enumerable.each_object    { |term| puts term.inspect }
enumerable.each_term      { |term| puts term.inspect }

@example Obtaining all statements

enumerable.statements  #=> [RDF::Statement(subject1, predicate1, object1), ...]
enumerable.triples     #=> [[subject1, predicate1, object1], ...]
enumerable.quads       #=> [[subject1, predicate1, object1, graph_name1], ...]

@example Obtaining all unique values

enumerable.subjects(unique: true)    #=> [subject1, subject2, subject3, ...]
enumerable.predicates(unique: true)  #=> [predicate1, predicate2, predicate3, ...]
enumerable.objects(unique: true)     #=> [object1, object2, object3, ...]
enumerable.graph_names(unique: true) #=> [graph_name1, graph_name2, graph_name3, ...]

@see RDF::Graph @see RDF::Repository

Public Instance Methods

canonicalize() click to toggle source

Enumerates each statement using its canonical representation.

@note This is updated by ‘RDF::Normalize` to also canonicalize blank nodes.

@return [RDF::Enumerable]

# File lib/rdf/mixin/enumerable.rb, line 731
def canonicalize
  this = self
  Enumerable::Enumerator.new do |yielder|
    this.send(:each_statement) {|y| yielder << y.canonicalize}
  end
end
canonicalize!() click to toggle source

Mutating canonicalization not supported

@raise NotImplementedError

# File lib/rdf/mixin/enumerable.rb, line 742
def canonicalize!
  raise NotImplementedError, "Canonicalizing enumerables not supported"
end
dump(*args, **options) click to toggle source

Returns a serialized string representation of ‘self`.

Before calling this method you may need to explicitly require a serialization extension for the specified format.

@example Serializing into N-Triples format

require 'rdf/ntriples'
ntriples = enumerable.dump(:ntriples)

@param [Array<Object>] args

if the last argument is a hash, it is passed as options to
{RDF::Writer.dump}.

@return [String] @see RDF::Writer.dump @raise [RDF::WriterError] if no writer found @since 0.2.0

# File lib/rdf/mixin/enumerable.rb, line 803
def dump(*args, **options)
  writer = RDF::Writer.for(*args)
  raise RDF::WriterError, "No writer found using #{args.inspect}" unless writer
  writer.dump(self, nil, **options)
end
each_graph() { |graph(graph_name: nil, data: self)| ... } click to toggle source

Iterates the given block for each RDF graph in ‘self`.

If no block was given, returns an enumerator.

The order in which graphs are yielded is undefined.

@overload each_graph

@yield  [graph]
  each graph
@yieldparam  [RDF::Graph] graph
@yieldreturn [void] ignored
@return [void]

@overload each_graph

@return [Enumerator<RDF::Graph>]

@see enum_graph @since 0.1.9

# File lib/rdf/mixin/enumerable.rb, line 701
def each_graph
  if block_given?
    yield RDF::Graph.new(graph_name: nil, data: self)
    # FIXME: brute force, repositories should override behavior
    if supports?(:graph_name)
      enum_statement.map(&:graph_name).uniq.compact.each do |graph_name|
        yield RDF::Graph.new(graph_name: graph_name, data: self)
      end
    end
  end
  enum_graph
end
each_object() { |value| ... } click to toggle source

Iterates the given block for each unique RDF object term.

If no block was given, returns an enumerator.

The order in which values are yielded is undefined.

@overload each_object

@yield  [object]
  each object term
@yieldparam  [RDF::Term] object
@yieldreturn [void] ignored
@return [void]

@overload each_object

@return [Enumerator<RDF::Term>]

@see enum_object

# File lib/rdf/mixin/enumerable.rb, line 506
def each_object # FIXME: deduplication
  if block_given?
    values = {}
    each_statement do |statement|
      value = statement.object
      unless value.nil? || values.include?(value)
        values[value] = true
        yield value
      end
    end
  end
  enum_object
end
each_predicate() { |value| ... } click to toggle source

Iterates the given block for each unique RDF predicate term.

If no block was given, returns an enumerator.

The order in which values are yielded is undefined.

@overload each_predicate

@yield  [predicate]
  each predicate term
@yieldparam  [RDF::URI] predicate
@yieldreturn [void] ignored
@return [void]

@overload each_predicate

@return [Enumerator<RDF::URI>]

@see enum_predicate

# File lib/rdf/mixin/enumerable.rb, line 439
def each_predicate
  if block_given?
    values = {}
    each_statement do |statement|
      value = statement.predicate
      unless value.nil? || values.include?(value.to_s)
        values[value.to_s] = true
        yield value
      end
    end
  end
  enum_predicate
end
each_quad() { |*to_quad| ... } click to toggle source

Iterates the given block for each RDF quad.

If no block was given, returns an enumerator.

The order in which quads are yielded is undefined.

@overload each_quad

@yield  [subject, predicate, object, graph_name]
  each quad
@yieldparam [RDF::Resource] subject
@yieldparam [RDF::URI]      predicate
@yieldparam [RDF::Term]     object
@yieldparam [RDF::Resource] graph_name
@yieldreturn [void] ignored
@return [void]

@overload each_quad

@return [Enumerator<Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)>]

@see enum_quad

# File lib/rdf/mixin/enumerable.rb, line 310
def each_quad
  if block_given?
    each_statement do |statement|
      yield(*statement.to_quad)
    end
  end
  enum_quad
end
each_statement(&block) click to toggle source

Iterates the given block for each RDF statement.

If no block was given, returns an enumerator.

The order in which statements are yielded is undefined.

@overload each_statement

@yield  [statement]
  each statement
@yieldparam  [RDF::Statement] statement
@yieldreturn [void] ignored
@return [void]

@overload each_statement

@return [Enumerator<RDF::Statement>]

@see enum_statement

# File lib/rdf/mixin/enumerable.rb, line 182
def each_statement(&block)
  if block_given?
    # Invoke {#each} in the containing class:
    each(&block)
  end
  enum_statement
end
each_subject() { |value| ... } click to toggle source

Iterates the given block for each unique RDF subject term.

If no block was given, returns an enumerator.

The order in which values are yielded is undefined.

@overload each_subject

@yield  [subject]
  each subject term
@yieldparam  [RDF::Resource] subject
@yieldreturn [void] ignored
@return [void]

@overload each_subject

@return [Enumerator<RDF::Resource>]

@see enum_subject

# File lib/rdf/mixin/enumerable.rb, line 373
def each_subject
  if block_given?
    values = {}
    each_statement do |statement|
      value = statement.subject
      unless value.nil? || values.include?(value.to_s)
        values[value.to_s] = true
        yield value
      end
    end
  end
  enum_subject
end
each_term() { |value| ... } click to toggle source

Iterates the given block for each unique RDF term (subject, predicate, object, or graph_name).

If no block was given, returns an enumerator.

The order in which values are yielded is undefined.

@overload each_term

@yield  [term]
  each term
@yieldparam  [RDF::Term] term
@yieldreturn [void] ignored
@return [void]

@overload each_term

@return [Enumerator<RDF::Term>]

@since 2.0 @see enum_term

# File lib/rdf/mixin/enumerable.rb, line 590
def each_term
  if block_given?
    values = {}
    each_statement do |statement|
      statement.terms.each do |value|
        unless values.include?(value.hash)
          values[value.hash] = true
          yield value
        end
      end
    end
  end
  enum_term
end
each_triple() { |*to_triple| ... } click to toggle source

Iterates the given block for each RDF triple.

If no block was given, returns an enumerator.

The order in which triples are yielded is undefined.

@overload each_triple

@yield  [subject, predicate, object]
  each triple
@yieldparam  [RDF::Resource] subject
@yieldparam  [RDF::URI]      predicate
@yieldparam  [RDF::Term]     object
@yieldreturn [void] ignored
@return [void]

@overload each_triple

@return [Enumerator<Array(RDF::Resource, RDF::URI, RDF::Term)>]

@see enum_triple

# File lib/rdf/mixin/enumerable.rb, line 247
def each_triple
  if block_given?
    each_statement do |statement|
      yield(*statement.to_triple)
    end
  end
  enum_triple
end
enum_graph() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_graph}.

@return [Enumerator<RDF::Graph>] @see each_graph @since 0.1.9

# File lib/rdf/mixin/enumerable.rb, line 720
def enum_graph
  enum_for(:each_graph)
end
Also aliased as: enum_graphs
enum_graphs()
Alias for: enum_graph
enum_object() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_object}.

@return [Enumerator<RDF::Term>] @see each_object

# File lib/rdf/mixin/enumerable.rb, line 525
def enum_object
  enum_for(:each_object)
end
Also aliased as: enum_objects
enum_objects()
Alias for: enum_object
enum_predicate() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_predicate}.

@return [Enumerator<RDF::URI>] @see each_predicate

# File lib/rdf/mixin/enumerable.rb, line 458
def enum_predicate
  enum_for(:each_predicate)
end
Also aliased as: enum_predicates
enum_predicates()
Alias for: enum_predicate
enum_quad() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_quad}.

@return [Enumerator<Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)>] @see each_quad

# File lib/rdf/mixin/enumerable.rb, line 324
def enum_quad
  Countable::Enumerator.new do |yielder|
    each_quad {|s, p, o, c| yielder << [s, p, o, c]}
  end
end
Also aliased as: enum_quads
enum_quads()
Alias for: enum_quad
enum_statement() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_statement}. FIXME: enum_for doesn’t seem to be working properly in JRuby 1.7, so specs are marked pending

@return [Enumerator<RDF::Statement>] @see each_statement

# File lib/rdf/mixin/enumerable.rb, line 197
def enum_statement
  # Ensure that statements are queryable, countable and enumerable
  this = self
  Queryable::Enumerator.new do |yielder|
    this.send(:each_statement) {|y| yielder << y}
  end
end
Also aliased as: enum_statements
enum_statements()
Alias for: enum_statement
enum_subject() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_subject}.

@return [Enumerator<RDF::Resource>] @see each_subject

# File lib/rdf/mixin/enumerable.rb, line 392
def enum_subject
  enum_for(:each_subject)
end
Also aliased as: enum_subjects
enum_subjects()
Alias for: enum_subject
enum_term() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_term}.

@return [Enumerator<RDF::Term>] @see each_term @since 2.0

# File lib/rdf/mixin/enumerable.rb, line 611
def enum_term
  enum_for(:each_term)
end
Also aliased as: enum_terms
enum_terms()
Alias for: enum_term
enum_triple() click to toggle source

Returns an enumerator for {RDF::Enumerable#each_triple}.

@return [Enumerator<Array(RDF::Resource, RDF::URI, RDF::Term)>] @see each_triple

# File lib/rdf/mixin/enumerable.rb, line 261
def enum_triple
  Countable::Enumerator.new do |yielder|
    each_triple {|s, p, o| yielder << [s, p, o]}
  end
end
Also aliased as: enum_triples
enum_triples()
Alias for: enum_triple
graph?(graph_name) click to toggle source

Returns ‘true` if `self` contains the given RDF graph_name.

@param [RDF::Resource, false] graph_name

Use value `false` to query for the default graph_name

@return [Boolean]

# File lib/rdf/mixin/enumerable.rb, line 638
def graph?(graph_name)
  enum_statement.any? {|s| s.graph_name == graph_name}
end
Also aliased as: has_graph?
graph_names(unique: true) click to toggle source

Returns all unique RDF graph names, other than the default graph.

@param unique (true) @return [Array<RDF::Resource>] @see each_graph @see enum_graph @since 2.0

# File lib/rdf/mixin/enumerable.rb, line 624
def graph_names(unique: true)
  unless unique
    enum_statement.map(&:graph_name).compact # TODO: optimize
  else
    enum_graph.map(&:graph_name).compact
  end
end
has_graph?(graph_name)
Alias for: graph?
has_object?(value)
Alias for: object?
has_predicate?(value)
Alias for: predicate?
has_quad?(quad)
Alias for: quad?
has_statement?(*args)
Alias for: statement?
has_subject?(value)
Alias for: subject?
has_term?(*args)
Alias for: term?
has_triple?(triple)
Alias for: triple?
include?(*args)
Alias for: statement?
invalid?() click to toggle source

Returns ‘true` if value is not valid

@return [Boolean] ‘true` or `false` @raise [NotImplementedError] unless enumerable supports validation @since 0.2.1

# File lib/rdf/mixin/enumerable.rb, line 117
def invalid?
  !valid?
end
object?(value) click to toggle source

Returns ‘true` if `self` contains the given RDF object term.

@param [RDF::Term] value @return [Boolean]

# File lib/rdf/mixin/enumerable.rb, line 483
def object?(value)
  enum_object.include?(value)
end
Also aliased as: has_object?
objects(unique: true) click to toggle source

Returns all unique RDF object terms.

@param unique (true) @return [Array<RDF::Term>] @see each_object @see enum_object

# File lib/rdf/mixin/enumerable.rb, line 470
def objects(unique: true)
  unless unique
    enum_statement.map(&:object) # TODO: optimize
  else
    enum_object.to_a
  end
end
predicate?(value) click to toggle source

Returns ‘true` if `self` contains the given RDF predicate term.

@param [RDF::URI] value @return [Boolean]

# File lib/rdf/mixin/enumerable.rb, line 417
def predicate?(value)
  enum_predicate.include?(value)
end
Also aliased as: has_predicate?
predicates(unique: true) click to toggle source

Returns all unique RDF predicate terms.

@param unique (true) @return [Array<RDF::URI>] @see each_predicate @see enum_predicate

# File lib/rdf/mixin/enumerable.rb, line 404
def predicates(unique: true)
  unless unique
    enum_statement.map(&:predicate) # TODO: optimize
  else
    enum_predicate.to_a
  end
end
project_graph(graph_name) { |statement| ... } click to toggle source

Limits statements to be from a specific graph.

If no block was given, returns an enumerator.

The order in which statements are yielded is undefined.

@overload project_graph(graph_name)

@param [RDF::Resource, nil] graph_name
  The name of the graph from which statements are taken.
  Use `nil` for the default graph.
@yield  [statement]
  each statement
@yieldparam  [RDF::Statement] statement
@yieldreturn [void] ignored
@return [void]

@overload project_graph(graph_name)

@param [RDF::Resource, false] graph_name
  The name of the graph from which statements are taken.
  Use `false` for the default graph.
@return [Enumerable]

@see each_statement @since 3.0

# File lib/rdf/mixin/enumerable.rb, line 668
def project_graph(graph_name)
  if block_given?
    self.each do |statement|
      yield statement if statement.graph_name == graph_name
    end
  else
    # Ensure that statements are queryable, countable and enumerable
    this = self
    Queryable::Enumerator.new do |yielder|
      this.send(:project_graph, graph_name) {|y| yielder << y}
    end
  end
end
quad?(quad) click to toggle source

Returns ‘true` if `self` contains the given RDF quad.

@param [Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)] quad @return [Boolean]

# File lib/rdf/mixin/enumerable.rb, line 284
def quad?(quad)
  quads.include?(quad)
end
Also aliased as: has_quad?
quads(**options) click to toggle source

Returns all RDF quads.

@param [Hash{Symbol => Boolean}] options @return [Array<Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)>] @see each_quad @see enum_quad

# File lib/rdf/mixin/enumerable.rb, line 275
def quads(**options)
  enum_statement.map(&:to_quad) # TODO: optimize
end
statement?(*args) click to toggle source

@overload statement?

Returns `false` indicating this is not an RDF::Statemenet.
@return [Boolean]
@see RDF::Value#statement?

@overload statement?(statement)

Returns `true` if `self` contains the given RDF statement.

@param  [RDF::Statement] statement
@return [Boolean]
# File lib/rdf/mixin/enumerable.rb, line 153
def statement?(*args)
  case args.length
  when 0 then false
  when 1
    args.first && !enum_statement.find { |s| s.eql?(args.first) }.nil?        
  else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)")
  end
end
Also aliased as: has_statement?, include?
statements(**options) click to toggle source

Returns all RDF statements.

@param [Hash{Symbol => Boolean}] options @return [Array<RDF::Statement>] @see each_statement @see enum_statement

# File lib/rdf/mixin/enumerable.rb, line 139
def statements(**options)
  enum_statement.to_a
end
subject?(value) click to toggle source

Returns ‘true` if `self` contains the given RDF subject term.

@param [RDF::Resource] value @return [Boolean]

# File lib/rdf/mixin/enumerable.rb, line 351
def subject?(value)
  enum_subject.include?(value)
end
Also aliased as: has_subject?
subjects(unique: true) click to toggle source

Returns all unique RDF subject terms.

@param unique (true) @return [Array<RDF::Resource>] @see each_subject @see enum_subject

# File lib/rdf/mixin/enumerable.rb, line 338
def subjects(unique: true)
  unless unique
    enum_statement.map(&:subject) # TODO: optimize
  else
    enum_subject.to_a
  end
end
supports?(feature) click to toggle source

Returns ‘true` if this enumerable supports the given `feature`.

Supported features include:

* `:graph_name` supports statements with a graph_name, allowing multiple named graphs
* `:inference` supports RDFS inferrence of queryable contents.
* `:literal_equality' preserves [term-equality](https://www.w3.org/TR/rdf11-concepts/#dfn-literal-term-equality) for literals. Literals are equal only if their lexical values and datatypes are equal, character by character. Literals may be "inlined" to value-space for efficiency only if `:literal_equality` is `false`.
* `:validity` allows a concrete Enumerable implementation to indicate that it does or does not support valididty checking. By default implementations are assumed to support validity checking.
* `:skolemize` supports [Skolemization](https://www.w3.org/wiki/BnodeSkolemization) of an `Enumerable`. Implementations supporting this feature must implement a `#skolemize` method, taking a base URI used for minting URIs for BNodes as stable identifiers and a `#deskolemize` method, also taking a base URI used for turning URIs having that prefix back into the same BNodes which were originally skolemized.
* `:rdf_full` supports RDF 1.2 Full profile, including support for embedded Triple Terms.
* `:quoted_triples` supports RDF-star quoted triples.
* `:base_direction` supports RDF 1.2 directional language-tagged strings.

@param [Symbol, to_sym] feature @return [Boolean] @since 0.3.5

# File lib/rdf/mixin/enumerable.rb, line 93
def supports?(feature)
  feature == :validity || feature == :literal_equality
end
term?(*args) click to toggle source

@overload term?

Returns `false` indicating this is not an RDF::Statemenet.
@see RDF::Value#statement?
@return [Boolean]

@overload term?(value)

Returns `true` if `self` contains the given RDF subject term.

@param  [RDF::Resource] value
@return [Boolean]
@since 2.0
Calls superclass method
# File lib/rdf/mixin/enumerable.rb, line 563
def term?(*args)
  case args.length
  when 0 then super
  when 1 then args.first && enum_term.include?(args.first)
  else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)")
  end
end
Also aliased as: has_term?
terms(unique: true) click to toggle source

Returns all unique RDF terms (subjects, predicates, objects, and graph_names).

@example finding all Blank Nodes used within an enumerable

enumberable.terms.select(&:node?)

@param unique (true) @return [Array<RDF::Resource>] @since 2.0 @see each_resource @see enum_resource

# File lib/rdf/mixin/enumerable.rb, line 541
def terms(unique: true)
  unless unique
    enum_statement.
      map(&:terms).
      flatten.
      compact
  else
    enum_term.to_a
  end
end
to_a() click to toggle source

Returns all RDF statements in ‘self` as an array.

Mixes in ‘RDF::Enumerable` into the returned object.

@return [Array]

Calls superclass method
# File lib/rdf/mixin/enumerable.rb, line 752
def to_a
  super.extend(RDF::Enumerable)
end
to_h() click to toggle source

Returns all RDF object terms indexed by their subject and predicate terms.

The return value is a ‘Hash` instance that has the structure: `{subject => {predicate => [*objects]}}`.

@return [Hash]

# File lib/rdf/mixin/enumerable.rb, line 776
def to_h
  result = {}
  each_statement do |statement|
    result[statement.subject] ||= {}
    values = (result[statement.subject][statement.predicate] ||= [])
    values << statement.object unless values.include?(statement.object)
  end
  result
end
to_set() click to toggle source

Returns all RDF statements in ‘self` as a set.

Mixes in ‘RDF::Enumerable` into the returned object.

@return [Set] @since 0.2.0

Calls superclass method
# File lib/rdf/mixin/enumerable.rb, line 763
def to_set
  require 'set' unless defined?(::Set)
  super.extend(RDF::Enumerable)
end
triple?(triple) click to toggle source

Returns ‘true` if `self` contains the given RDF triple.

@param [Array(RDF::Resource, RDF::URI, RDF::Term)] triple @return [Boolean]

# File lib/rdf/mixin/enumerable.rb, line 222
def triple?(triple)
  triples.include?(triple)
end
Also aliased as: has_triple?
triples(**options) click to toggle source

Returns all RDF triples.

@param [Hash{Symbol => Boolean}] options @return [Array<Array(RDF::Resource, RDF::URI, RDF::Term)>] @see each_triple @see enum_triple

# File lib/rdf/mixin/enumerable.rb, line 213
def triples(**options)
  enum_statement.map(&:to_triple) # TODO: optimize
end
valid?() click to toggle source

Returns ‘true` if all statements are valid

@return [Boolean] ‘true` or `false` @raise [NotImplementedError] unless enumerable supports validation @since 0.3.11

# File lib/rdf/mixin/enumerable.rb, line 103
def valid?
  raise NotImplementedError, "#{self.class} does not support validation" unless supports?(:validity)
  each_statement do |s|
    return false if s.invalid?
  end
  true
end
validate()
Alias for: validate!
validate!() click to toggle source

Default validate! implementation, overridden in concrete classes @return [RDF::Enumerable] ‘self` @raise [ArgumentError] if the value is invalid @since 0.3.9

# File lib/rdf/mixin/enumerable.rb, line 126
def validate!
  raise ArgumentError if supports?(:validity) && invalid?
  self
end
Also aliased as: validate

Protected Instance Methods

enum_for(method = :each, *args) click to toggle source

@private @param [Symbol, to_sym] method @return [Enumerator] @see Object#enum_for

# File lib/rdf/mixin/enumerable.rb, line 841
def enum_for(method = :each, *args)
  # Ensure that enumerators are, themselves, queryable
  this = self
  Enumerable::Enumerator.new do |yielder|
    this.send(method, *args) {|*y| yielder << (y.length > 1 ? y : y.first)}
  end
end
Also aliased as: to_enum
method_missing(meth, *args) click to toggle source

@overload to_writer

Implements #to_writer for each available instance of {RDF::Writer},
based on the writer symbol.

@return [String]
@see {RDF::Writer.sym}
Calls superclass method
# File lib/rdf/mixin/enumerable.rb, line 818
def method_missing(meth, *args)
  writer = RDF::Writer.for(meth.to_s[3..-1].to_sym) if meth.to_s[0,3] == "to_"
  if writer
    writer.buffer(standard_prefixes: true) {|w| w << self}
  else
    super
  end
end
respond_to_missing?(name, include_private = false) click to toggle source

@note this instantiates an writer; it could probably be done more

efficiently by refactoring `RDF::Reader` and/or `RDF::Format` to expose
a list of valid format symbols.
Calls superclass method
# File lib/rdf/mixin/enumerable.rb, line 831
def respond_to_missing?(name, include_private = false)
  return RDF::Writer.for(name.to_s[3..-1].to_sym) if name.to_s[0,3] == 'to_'
  super
end
to_enum(method = :each, *args)
Alias for: enum_for