Sha256: 65149f4e4f15b68e7f2526daaebe5ee38b1e7ae70d0ffa9237b95d57afb6af8e

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Alf
  #
  # Marker module for all elements implementing tuple iterators.
  #
  # At first glance, an iterator is nothing else than an Enumerable that serves
  # tuples (represented by ruby hashes). However, this module helps Alf's
  # internal classes to recognize enumerables that may safely be considered as
  # tuple iterators from other enumerables. For this reason, all elements that
  # would like to participate to an iteration chain (that is, an logical
  # operator implementation) should be marked with this module. This is the case
  # for all Readers and Operators defined in Alf.
  #
  module Iterator
    include Enumerable

    # Converts this iterator to an in-memory Relation.
    #
    # @return [Relation] a relation instance, as the set of tuples that would be yield by
    # this iterator.
    def to_relation
      Relation::new(self.to_set)
    end
    alias :to_rel :to_relation

    require 'alf/iterator/class_methods'
    require 'alf/iterator/proxy'
  end # module Iterator
end # module Alf

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf/iterator.rb
alf-0.12.1 lib/alf/iterator.rb