class Enumerator::Product
Public Class Methods
Source
# File lib/backports/3.2.0/enumerator/product.rb, line 44 def initialize(*enums) @__enums = enums end
rubocop:disable Lint/MissingSuper
Public Instance Methods
Source
# File lib/backports/3.2.0/enumerator/product.rb, line 50 def each(&block) return self unless block __execute(block, [], @__enums) self end
Source
# File lib/backports/3.2.0/enumerator/product.rb, line 81 def rewind @__enums.each do |enum| enum.rewind if enum.respond_to?(:rewind) end self end
Source
# File lib/backports/3.2.0/enumerator/product.rb, line 69 def size total_size = 1 @__enums.each do |enum| return nil unless enum.respond_to?(:size) size = enum.size return size if size == 0 || size == nil || size == Float::INFINITY || size == -Float::INFINITY return nil unless size.is_a?(Integer) total_size *= size end total_size end
Private Instance Methods
Source
# File lib/backports/3.2.0/enumerator/product.rb, line 56 def __execute(block, values, enums) if enums.empty? block.yield values else enum, *enums = enums enum.each do |val| __execute(block, [*values, val], enums) end end nil end
Source
# File lib/backports/3.2.0/enumerator/product.rb, line 88 def initialize_copy(other) return self if equal?(other) raise TypeError unless Product === other super(other) other_enums = other.instance_variable_get(:@__enums) raise ArgumentError, "uninitialized product" unless other_enums @__enums = other_enums self end
Calls superclass method