Skip to content

Instantly share code, notes, and snippets.

@tatey
Created June 4, 2012 02:36
Show Gist options
  • Select an option

  • Save tatey/2866010 to your computer and use it in GitHub Desktop.

Select an option

Save tatey/2866010 to your computer and use it in GitHub Desktop.
class AddressBook
attr_accessor :contacts
def initialize
@contacts = {}
end
def numbers *names
names.map do |name|
@contacts[name]
end.flatten
end
def register_contact name, numbers
@contacts[name] = numbers
end
def self.default_book
return @book if defined? @book
book = new
book.register_contact :all, all_mobile_numbers
book.register_contact :all_staff, all_staff_numbers
book.register_contact :customer1, customer1_numbers
book.register_contact :customer2, customer2_numbers
@book = book
end
end
AddressBook.default_book
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment