Module: Jinx::Math

Defined in:
lib/jinx/helpers/math.rb

Class Method Summary collapse

Class Method Details

.max(*args) ⇒ Numeric

Returns the largest number.

Parameters:

  • the (<Numeric>)

    numbers to compare

Returns:



11
12
13
# File 'lib/jinx/helpers/math.rb', line 11

def self.max(*args)
  args.inject { |m, n| m < n ? n : m }
end

.min(*args) ⇒ Numeric

Returns the smallest number.

Parameters:

  • the (<Numeric>)

    numbers to compare

Returns:

  • (Numeric)

    the smallest number



5
6
7
# File 'lib/jinx/helpers/math.rb', line 5

def self.min(*args)
  args.inject { |m, n| m < n ? m : n }
end

.numeric?(value) ⇒ Boolean

Returns whether the value is a Ruby or Java number.

Parameters:

  • value

    the value to check

Returns:

  • (Boolean)

    whether the value is a Ruby or Java number



17
18
19
# File 'lib/jinx/helpers/math.rb', line 17

def self.numeric?(value)
  Numeric === value or Java::JavaLang::Number === value
end