Skip to content

Instantly share code, notes, and snippets.

@LolWalid
Last active January 28, 2016 15:20
Show Gist options
  • Save LolWalid/9fa1ccddae6713f19c4a to your computer and use it in GitHub Desktop.
Save LolWalid/9fa1ccddae6713f19c4a to your computer and use it in GitHub Desktop.
How to define private class method ruby
class CoolClass
# This is the documentation
# # return a string containing Something Cool or Something Coolest !
# arg1 = boolean # Default value to true
# CoolClass.cool_method # return 'Something Cool'
# CoolClass.cool_method(false) # return 'Something Coolest'
def self.cool_method(arg1 = true)
return public_method1 if arg1
private_method1
end
class << self
def public_method1
'Something Cool'
end
private
def private_method1
'Something Coolest !'
end
end
end
@yannvery
Copy link

Just to be clear, this is a 'How to' make private class method in ruby.
Very hepfull.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment