To embed a module in a class, you use the include statement in the class: include modulename
module Week
First_day = "Sunday"
def Week.weeks_in_month
puts "You have four weeks in a month"
end
def Week.weeks_in_year
puts "You have 52 weeks in a year"
end
end
class Decade
include Week
no_of_yrs=10
def no_of_months
puts Week::First_day
number=10*12
puts number
end
end
d1=Decade.new
puts Week::First_day
Week.weeks_in_month
Week.weeks_in_year
d1.no_of_months
Related examples in the same category