Created
November 29, 2012 12:23
-
-
Save Shinpeim/4168684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Nyan | |
def nyan | |
"nyan" | |
end | |
extend self | |
end | |
class Neko | |
include Nyan | |
def mew | |
nyan | |
end | |
end | |
p Nyan.nyan # => nyan | |
p Neko.new.mew # => nyan | |
p Neko.new.nyan # => nyan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Piyo | |
def piyo | |
"piyo" | |
end | |
module_function :piyo | |
end | |
class Hiyoko | |
include Piyo | |
def chun | |
piyo | |
end | |
end | |
p Piyo.piyo # => piyo | |
p Hiyoko.new.chun # => piyo | |
p Hiyoko.new.piyo # => private method `piyo' called NoMethodError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Wan | |
class << self | |
def wan | |
"wan" | |
end | |
end | |
end | |
class Inu | |
include Wan | |
def bow | |
wan | |
end | |
end | |
p Wan.wan # wan | |
p Inu.new.bow # => NoMethodError | |
p Inu.new.wan # => NoMethodError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment