module Dataset::IteratingBasedOnNext

Provides `#each` (which can return an `Iterator`) and `#to_a` based on `#next`

Public Instance Methods

collect()

@see collect

Alias for: map
each() { |next| ... } click to toggle source

Yields on each [inputs, targets] pair. @return [nil|Iterator] `block_given? ? nil : Iterator`

# File lib/data_modeler/dataset/helper.rb, line 42
def each
  reset_iteration
  return enum_for(:each) unless block_given?
  loop { yield self.next }
  nil
end
map() { |next| ... } click to toggle source

Yields on each `[inputs, targets]` pair, collecting the input. @return [Array|Iterator] `block_given? ? nil : Iterator`

# File lib/data_modeler/dataset/helper.rb, line 51
def map
  reset_iteration
  return enum_for(:collect) unless block_given?
  [].tap { |ret| loop { ret << yield(self.next) } }
end
Also aliased as: collect
to_a() click to toggle source

@return [Array]

# File lib/data_modeler/dataset/helper.rb, line 61
def to_a
  each.to_a
end