Sha256: a6711f14f7f0e64701f2da9972a3b9480889cdcc3616b3500b2a4cf5118ed20c

Contents?: true

Size: 359 Bytes

Versions: 1

Compression:

Stored size: 359 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

          return false if result.class != other.class

          result = result.send(m, other)
        end
        true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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