Created
December 27, 2017 23:14
-
-
Save onelharrison/fbc95c29031b4cc33a74561ca7905d59 to your computer and use it in GitHub Desktop.
Code snippet showing how to define public class methods in Ruby.
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 Toyota < Car | |
class << self | |
def name | |
"Toyota #{superclass}" | |
end | |
end | |
end | |
# => Toyota.name | |
# "Toyota Car" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment