Module: Cowtech::Extensions::Math::ClassMethods
- Defined in:
- lib/cowtech-extensions/math.rb
Overview
General methods.
Instance Method Summary collapse
-
#max(*args) ⇒ Object
Returns the maximum value in the arguments.
-
#min(*args) ⇒ Object
Returns the minimum value in the arguments.
Instance Method Details
#max(*args) ⇒ Object
Returns the maximum value in the arguments
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cowtech-extensions/math.rb', line 35 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 |
#min(*args) ⇒ Object
Returns the minimum value in the arguments
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cowtech-extensions/math.rb', line 19 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 |