Sha256: 9f912f6c41197bcbf2a5ef7cc40d2b66eda33349cb44be39e3e3eb37ac4a1d59

Contents?: true

Size: 990 Bytes

Versions: 38

Compression:

Stored size: 990 Bytes

Contents

# encoding: utf-8
#
# This file is part of the lazier gem. Copyright (C) 2013 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)
        args.ensure_array.flatten.min
      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)
        args.ensure_array.flatten.max
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
lazier-3.3.5 lib/lazier/math.rb
lazier-3.3.3 lib/lazier/math.rb
lazier-3.3.2 lib/lazier/math.rb
lazier-3.3.1 lib/lazier/math.rb
lazier-3.3.0 lib/lazier/math.rb
lazier-3.2.7 lib/lazier/math.rb
lazier-3.2.6 lib/lazier/math.rb
lazier-3.2.5 lib/lazier/math.rb
lazier-3.2.4 lib/lazier/math.rb
lazier-3.2.3 lib/lazier/math.rb
lazier-3.2.2 lib/lazier/math.rb
lazier-3.2.1 lib/lazier/math.rb
lazier-3.2.0 lib/lazier/math.rb
lazier-3.1.0 lib/lazier/math.rb
lazier-3.0.1 lib/lazier/math.rb
lazier-3.0.0 lib/lazier/math.rb
lazier-2.8.1 lib/lazier/math.rb
lazier-2.8.0 lib/lazier/math.rb
lazier-2.7.0 lib/lazier/math.rb
lazier-2.6.7 lib/lazier/math.rb