Skip to content

Instantly share code, notes, and snippets.

@onelharrison
Created December 27, 2017 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onelharrison/fbc95c29031b4cc33a74561ca7905d59 to your computer and use it in GitHub Desktop.
Save onelharrison/fbc95c29031b4cc33a74561ca7905d59 to your computer and use it in GitHub Desktop.
Code snippet showing how to define public class methods in Ruby.
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