Sha256: fa8cff2fc77ad6230067a74f25549f1bf8595d8c77be04b1156dfa39b2e48360

Contents?: true

Size: 881 Bytes

Versions: 21

Compression:

Stored size: 881 Bytes

Contents

module Vim
  module Flavor
    EnumerableExtension = ::Enumerable

    module EnumerableExtension
      def before_each(&block)
        vs = each
        Enumerator.new do |y|
          loop do
            v = vs.next
            block.call(v)
            y << v
          end
        end
      end

      def after_each(&block)
        vs = each
        Enumerator.new do |y|
          loop do
            v = vs.next
            y << v
            block.call(v)
          end
        end
      end

      def on_failure(&block)
        vs = each
        Enumerator.new do |y|
          v = nil
          begin
            loop do
              v = vs.next
              y << v
              v = nil
            end
          rescue StopIteration
            raise
          rescue
            block.call(v)
            raise
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
vim-flavor-4.0.3 lib/vim-flavor/enumerableextension.rb
vim-flavor-4.0.2 lib/vim-flavor/enumerableextension.rb
vim-flavor-4.0.1 lib/vim-flavor/enumerableextension.rb
vim-flavor-4.0.0 lib/vim-flavor/enumerableextension.rb
vim-flavor-3.0.0 lib/vim-flavor/enumerableextension.rb
vim-flavor-2.2.2 lib/vim-flavor/enumerableextension.rb
vim-flavor-2.2.1 lib/vim-flavor/enumerableextension.rb
vim-flavor-2.2.0 lib/vim-flavor/enumerableextension.rb
vim-flavor-2.1.1 lib/vim-flavor/enumerableextension.rb
vim-flavor-2.1.0 lib/vim-flavor/enumerableextension.rb
vim-flavor-2.0.0 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.1.5 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.1.4 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.1.3 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.1.2 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.1.1 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.1.0 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.0.3 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.0.2 lib/vim-flavor/enumerableextension.rb
vim-flavor-1.0.1 lib/vim-flavor/enumerableextension.rb