Sha256: 1e1d589a82b5ca2d9e2ff657a784983ca594dce40d2198142b48932e8737df04
Contents?: true
Size: 1.26 KB
Versions: 6
Compression:
Stored size: 1.26 KB
Contents
# encoding: utf-8 # # This file is part of the lazier gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>. # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php. # module Lazier # Utility methods for Math module. module Math extend ::ActiveSupport::Concern # General methods. module ClassMethods # Returns the minimum value in the arguments # # @param args [Array] A collection of object to compare (with the `<` operator). # @return [Object] The minimum value or `nil` (if the collection is empty). def min(*args) rv = nil args = args.ensure_array.flatten if args.length > 0 then rv = args[0] args.each do |a| rv = a if a < rv end end rv end # Returns the maximum value in the arguments # # @param args [Array] A collection of object to compare (with the `>` operator). # @return [Object] The maximum value or `nil` (if the collection is empty). def max(*args) rv = nil args = args.ensure_array.flatten if args.length > 0 then rv = args[0] args.each do |a| rv = a if a > rv end end rv end end end end
Version data entries
6 entries across 6 versions & 1 rubygems