Skip to content

Instantly share code, notes, and snippets.

@j3ck
Created July 25, 2017 13:05
Show Gist options
  • Save j3ck/5e9cf0af9b553f06808a90813bae84cf to your computer and use it in GitHub Desktop.
Save j3ck/5e9cf0af9b553f06808a90813bae84cf to your computer and use it in GitHub Desktop.
module MyModule
# self here is MyModule
@species = "frog"
@color = "red polka-dotted"
@log = []
def self.log(msg)
# self here is still MyModule, so the instance variables are still available
@log << msg
end
def self.show_log
puts @log.map { |m| "A #@color #@species says #{m.inspect}" }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment