module Compute

Requires a class with num attribute(which is Numeric) and it’s reader

Constants

OPERATIONS

Public Instance Methods

method_missing(method, arg=nil) click to toggle source
Calls superclass method
# File lib/modules/compute.rb, line 6
def method_missing(method, arg=nil)
  if OPERATIONS.include?(method)
    self.class.new(num.send(method, arg.num))
  else
    super
  end
end
num_mod(number) click to toggle source
# File lib/modules/compute.rb, line 14
def num_mod(number)
  num.abs.modulo(number)
end