Skip to content

Instantly share code, notes, and snippets.

@Ebonkuab
Created January 12, 2016 18:13
Show Gist options
  • Save Ebonkuab/42c5b61ffb7254ed3bbc to your computer and use it in GitHub Desktop.
Save Ebonkuab/42c5b61ffb7254ed3bbc to your computer and use it in GitHub Desktop.
Starter code for the Contact List app
require_relative 'contact'
# Interfaces between a user and their contact list. Reads from and writes to standard I/O.
class ContactList
# TODO: Implement user interaction. This should be the only file where you use `puts` and `gets`.
end
require 'csv'
# Represents a person in an address book.
class Contact
attr_accessor :name, :email
def initialize(name, email)
# TODO: Assign parameter values to instance variables.
end
# Provides functionality for managing a list of Contacts in a database.
class << self
# Returns an Array of Contacts loaded from the database.
def all
# TODO: Return an Array of Contact instances made from the data in 'contacts.csv'.
end
# Creates a new contact, adding it to the database, returning the new contact.
def create(name, email)
# TODO: Instantiate a Contact, add its data to the 'contacts.csv' file, and return it.
end
# Returns the contact with the specified id. If no contact has the id, returns nil.
def find(id)
# TODO: Find the Contact in the 'contacts.csv' file with the matching id.
end
# Returns an array of contacts who match the given term.
def search(term)
# TODO: Select the Contact instances from the 'contacts.csv' file whose name or email attributes contain the search term.
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment