Why does the total count of methods reduce, from 81 to 46 while instantiating an object from 'Class' class-objects?
Here's the code I'm running:
class Automobile
def wheels(wheel)
puts "#{wheel}"
end
end
class Car < Automobile
def gears
puts "Automatic Transmission"
end
end
limo = Car.new
benz = Automobile.new
puts Automobile.methods.count
puts Car.methods.count
puts benz.methods.count
puts limo.methods.count
I guess subclass is not inheriting certain methods, I thought they are class methods, so I did some tests and realized methods displayed by "puts Anyclass.methods" are not class methods. They must be instance methods.
How is this achieved in Ruby, to deter a subclass from inheriting certain methods?