Last active
September 16, 2015 01:05
-
-
Save YumaInaura/17a018aed4de0226e636 to your computer and use it in GitHub Desktop.
Ruby: 絶対パスでメソッドを呼び出す。 ref: http://qiita.com/Yinaura/items/bbad6d788f2a0d5463f0
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
class Book | |
def self.example | |
p 'Class' | |
end | |
end | |
module Example | |
class Book | |
#このモジュールの example を呼ぶ | |
def self.call_module_method | |
Book.example | |
end | |
# 普通のClass の example を呼ぶ | |
def self.call_class_method | |
::Book.example | |
end | |
def self.example | |
p 'Module' | |
end | |
end | |
end | |
Example::Book.call_module_method | |
Example::Book.call_class_method |
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
Book.example |
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
::Book.example |
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
::Book.example |
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" | |
"Class" |
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" | |
"Class" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment