P
petermichaux
Hi,
I'm trying to call a modual method from a class method with the same
name. The code I tried and error are below. I think my "Debug.whoAmI?"
line is the problem. What is the correct syntax to call the moduals
method?
Thanks,
Peter
==== CODE ===
module Debug
def whoAmI?
"#{self.class.name}"
end
end
class EightTrack
include Debug
def whoAmI?
Debug.whoAmI?
end
end
et = EightTrack.new
p et.whoAmI?
=== OUTPUT ERROR ===
peter$ ruby mixin.rb
mixin.rb:10:in `whoAmI?': undefined method `whoAmI?' for Debug:Module
(NoMethodError)
from mixin.rb:16
I'm trying to call a modual method from a class method with the same
name. The code I tried and error are below. I think my "Debug.whoAmI?"
line is the problem. What is the correct syntax to call the moduals
method?
Thanks,
Peter
==== CODE ===
module Debug
def whoAmI?
"#{self.class.name}"
end
end
class EightTrack
include Debug
def whoAmI?
Debug.whoAmI?
end
end
et = EightTrack.new
p et.whoAmI?
=== OUTPUT ERROR ===
peter$ ruby mixin.rb
mixin.rb:10:in `whoAmI?': undefined method `whoAmI?' for Debug:Module
(NoMethodError)
from mixin.rb:16