Sha256: 2393012764a4790f21d087fa4af487ac7f34a60f89a44c25a741fe8ad364c37c

Contents?: true

Size: 341 Bytes

Versions: 7

Compression:

Stored size: 341 Bytes

Contents

module CardsLib::Refinements
  module InjectWhile
    refine Array do
      def inject_while?(m)
        result, *array = self.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

7 entries across 7 versions & 1 rubygems

Version Path
cards_lib-0.2.4 lib/cards_lib/refinements.rb
cards_lib-0.2.3 lib/cards_lib/refinements.rb
cards_lib-0.2.2 lib/cards_lib/refinements.rb
cards_lib-0.2.1 lib/cards_lib/refinements.rb
cards_lib-0.2.0 lib/cards_lib/refinements.rb
cards_lib-0.1.2 lib/cards_lib/refinements.rb
cards_lib-0.1.1 lib/cards_lib/refinements.rb