def to_enum(match: '*', count: 10)
      pattern = Regexp.compile("^#{Regexp.escape(match).gsub('\*', '.*')}$")

      return Enumerator.new do |yielder|
        offset = 0
        loop do
          items = slice(start: offset, length: offset + count)

          offset += items.size
          matched = items.select { |item| item =~ pattern }
          yielder << matched unless matched.empty?

          raise StopIteration if items.size < count
        end
      end
    end
def to_enum(match: '*', count: 10)
      pattern = Regexp.compile("^#{Regexp.escape(match).gsub('\*', '.*')}$")

      return Enumerator.new do |yielder|
        offset = 0
        loop do
          items = slice(start: offset, length: offset + count)

          offset += items.size
          matched = items.select { |item| item =~ pattern }
          yielder << matched unless matched.empty?

          raise StopIteration if items.size < count
        end
      end
    end
Since the list can be modified in between loops, this does not guarantee
 completion of the operation, nor that every single element of the list
 will be visited once; rather, it guarantees that it loops until no more
 elements are returned, using an incrementing offset.
 This means that should elements be removed in the meantime, they will
 not be seen, and others might be skipped as a result of this.
 If elements are added, it is however not an issue (although keep in mind
 that if elements are added faster than consumed, this can loop forever)
 @return [Enumerator] base enumerator to iterate of the list elements