module RbExt::Integer

Public Instance Methods

cross_product() click to toggle source

Calculates the cross product of this integer

Example:

12345.cross_product   # => 120
# File lib/rb_ext/integer.rb, line 35
def cross_product
  _self = self; product = 1
  
  while _self > 0
    product *= _self % 10
    _self /= 10
  end
  
  return product
end
cross_sum() click to toggle source

Calculates the cross sum of this integer

Example:

123.cross_sum   # => 6
# File lib/rb_ext/integer.rb, line 19
def cross_sum
  _self = self; sum = 0
  
  while _self > 0
    sum += _self % 10
    _self /= 10
  end
  
  return sum
end
to_minutes_and_seconds() click to toggle source

Returns an array with this Fixnum calculated as minutes (the first element) and seconds (the second element)

Example:

3601.to_minutes_and_seconds   # => [60, 1] meaning: 3601 seconds are 60 minutes and 1 second
# File lib/rb_ext/integer.rb, line 10
def to_minutes_and_seconds
  [self / 60, self % 60]
end