Sha256: 51c31eb63e6a4842147ec4ab45af24ed3c6790d6af48baf7b53782ed45bd0495

Contents?: true

Size: 336 Bytes

Versions: 1

Compression:

Stored size: 336 Bytes

Contents

module CardsLib::Refinements
  module InjectWhile
    refine Array do
      def inject_while?(m)
        result, *array = dup
        loop do
          break if array.empty?
          other = array.shift

          result = result.send(m, other)
          return false unless result
        end
        true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cards_lib-0.2.5 lib/cards_lib/refinements.rb