Sha256: d6e40c167f5f3479e4c9913e35ac1a4f8db519c39486c82858c555af3918d3eb
Contents?: true
Size: 896 Bytes
Versions: 6
Compression:
Stored size: 896 Bytes
Contents
# helpers: deny_frozen_access # backtick_javascript: true class ::Enumerator class self::Chain < self def initialize(*enums) `$deny_frozen_access(self)` @enums = enums @iterated = [] @object = self end def each(*args, &block) return to_enum(:each, *args) { size } unless block_given? @enums.each do |enum| @iterated << enum enum.each(*args, &block) end self end def size(*args) accum = 0 @enums.each do |enum| size = enum.size(*args) return size if [nil, ::Float::INFINITY].include? size accum += size end accum end def rewind @iterated.reverse_each do |enum| enum.rewind if enum.respond_to? :rewind end @iterated = [] self end def inspect "#<Enumerator::Chain: #{@enums.inspect}>" end end end
Version data entries
6 entries across 6 versions & 1 rubygems