Skip to content

Instantly share code, notes, and snippets.

View zzidante's full-sized avatar

Zzi/Mel zzidante

  • Vancouver
View GitHub Profile
@zzidante
zzidante / track_instances_with_class_methods.rb
Created December 13, 2017 21:56
An example of tracking and counting instances of a Class using class methods.
class Dog
# make class methods to track & store instances
@@count = 0
@@instances = []
# allow access/overwrite to name variable
attr_accessor :name
# instantiate and invoke tracking of class methods. Runs at creation of instance.
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>