module Swimmable
def swim
"#{ name } is swimming!"
end
end
module Fetchable
def fetch
"#{ name } is fetching!"
end
end
class Animal
attr_accessor :name
def initialize(name)
@name = name
end
def speak
"#{ name } is speaking!"
end
end
class Mammal < Animal
def warm_blooded?
true
end
end
class Dog < Mammal
include Swimmable
include Fetchable
def speak
"#{ name } is barking!"
end
end
fido = Dog.new('fido')
puts fido.swim
produce
fido is swimming!
Dog
Fetchable
Swimmable
Mammal
Animal
Object
Kernel
BasicObject