module Superpower
# instance method
def turn_invisible
...
end
# module method
def Superpower.turn_into_toad
...
end
module Fly
def flap_wings
...
end
end
end
Class Superman
include Superpower
...
def run_away
# how to call flap_wings?
# how to call turn_invisible?
end
def see_bad_guys(bad_guy = lex_luthor)
#is this correct?
Superpower.turn_into_toad(bad_guy)
end
end
Hi I saw some ruby code which I couldn't understand. How do you call flap_wings from within the Superman class? Is it possible to call an instance method from within the class? What is the difference between including modules and embedding modules? Why and when should you do that?