Sha256: 9ad1106c3b08c2ad33f6ef82aeebd8d202d8e685620064ab4bc04ec25667dfd6

Contents?: true

Size: 419 Bytes

Versions: 4

Compression:

Stored size: 419 Bytes

Contents

require 'githooker/core_ext/numbers/infinity'

class Array
  def min(&block)
    collection = block_given? ? collect { |obj| yield obj } : self
    collection.inject(Infinity) { |min, num|
      min = num < min ? num : min; min
    }
  end

  def max(&block)
    collection = block_given? ? collect { |obj| yield obj } : self
    collection.inject(0) { |max, num|
      max = num > max ? num : max; max
    }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
githooker-0.2.12 lib/githooker/core_ext/array/min_max.rb
githooker-0.2.11 lib/githooker/core_ext/array/min_max.rb
githooker-0.2.10 lib/githooker/core_ext/array/min_max.rb
githooker-0.2.0 lib/githooker/core_ext/array/min_max.rb