Sha256: 896ccd1ca62901c9d20c3229c9d2cd0d42a65e88e118468bf98a8abb802ccfc0

Contents?: true

Size: 973 Bytes

Versions: 6

Compression:

Stored size: 973 Bytes

Contents

# encoding: utf-8
#
# This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# 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 mapion of object to compare (with the `<` operator).
      # @return [Object] The minimum value or `nil` (if the mapion is empty).
      def min(*args)
        args.ensure_array.flatten.min
      end

      # Returns the maximum value in the arguments
      #
      # @param args [Array] A mapion of object to compare (with the `>` operator).
      # @return [Object] The maximum value or `nil` (if the mapion is empty).
      def max(*args)
        args.ensure_array.flatten.max
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lazier-3.5.7 lib/lazier/math.rb
lazier-3.5.6 lib/lazier/math.rb
lazier-3.5.5 lib/lazier/math.rb
lazier-3.5.4 lib/lazier/math.rb
lazier-3.5.3 lib/lazier/math.rb
lazier-3.5.2 lib/lazier/math.rb