Sha256: 2569e68eb660e69fecee07cbce2a9517dc665faf61cc72f5870b23f253bf790a

Contents?: true

Size: 567 Bytes

Versions: 26

Compression:

Stored size: 567 Bytes

Contents

unless Enumerable.method_defined? :minmax
  require 'backports/tools'

  module Enumerable
    def minmax
      return minmax{|a,b| a <=> b} unless block_given?
      first_time = true
      min, max = nil
      each do |object|
        if first_time
          min = max = object
          first_time = false
        else
          min = object if Backports.coerce_to_comparison(min, object, yield(min, object)) > 0
          max = object if Backports.coerce_to_comparison(max, object, yield(max, object)) < 0
        end
      end
      [min, max]
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
scout_realtime-1.0.5 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-1.0.4 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-1.0.3 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-1.0.3.pre lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-1.0.2 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-1.0.1 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-1.0.0 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-0.5.5 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-0.5.5.pre lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-0.5.4 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
backports-3.6.0 lib/backports/1.8.7/enumerable/minmax.rb
backports-3.5.0 lib/backports/1.8.7/enumerable/minmax.rb
backports-3.4.1 lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-0.5.3 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-0.5.2 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
scout_realtime-0.5.1 lib/vendor/backports-3.3.5/lib/backports/1.8.7/enumerable/minmax.rb
backports-3.4.0 lib/backports/1.8.7/enumerable/minmax.rb
backports-3.3.5 lib/backports/1.8.7/enumerable/minmax.rb
backports-3.3.4 lib/backports/1.8.7/enumerable/minmax.rb
backports-3.3.3 lib/backports/1.8.7/enumerable/minmax.rb