Skip to content

Instantly share code, notes, and snippets.

@perfectfoolish
Created July 15, 2013 03:41
Show Gist options
  • Save perfectfoolish/5997348 to your computer and use it in GitHub Desktop.
Save perfectfoolish/5997348 to your computer and use it in GitHub Desktop.
class Machine
@@users = {}
def initialize(username, password)
@username = username
@password = password
@@users[username] = password
@files = {}
end
def create(filename)
time = Time.now
@files[filename] = time
puts "#{filename} was created by #{@username} at #{time}."
end
def Machine.get_users
@@users
end
end
my_machine = Machine.new("eric", 01234)
your_machine = Machine.new("you", 56789)
my_machine.create("groceries.txt")
your_machine.create("todo.txt")
puts "Users: #{Machine.get_users}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment