Ruby Basicsl - Modules
module Math
def add(x, y)
x + y
end
def sub(x, y)
x - y
end
module More
def mod(x, y)
x % y
end
end
class Calculator
include Math
end
end
module Power
def get_horse_power
puts "Power of the horse !"
end
end
class MyCalculator < Math::Calculator
include Power
include Math::More
end
calc = MyCalculator.new
calc.get_horse_power
puts calc.add 1, 5
puts calc.sub 5, 4