Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
GEM
remote: https://rubygems.org/
specs:
minitest (5.8.1)

Expand Down
32 changes: 21 additions & 11 deletions address_book.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
require "./person.rb"
require 'csv'
class AddressBook
def initialize(csv_path)

end

def print_people

end

def search_person(person_name)

end
attr_accessor :people
def initialize(csv_path)
@book = []
CSV.foreach(csv_path) do |row|
@book << Person.new(row[0],row[1],row[2],row[3])
end
end
def print_people
@book.each do |person|
puts "# #{person.id},#{person.full_name},#{person.phone_number},#{person.city}"
end
end
def search_person(person_name)
@book.each do |person|
if person.full_name.include? person_name
puts "#{person.id},#{person.full_name},#{person.phone_number},#{person.city}"
end
end
end
end
2 changes: 1 addition & 1 deletion main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

address_book = AddressBook.new("people.csv")
address_book.print_people
address_book.search_person("Michael")
address_book.search_person("Emily")
7 changes: 7 additions & 0 deletions person.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
class Person

attr_accessor :id, :full_name, :phone_number, :city
def initialize(id,full_name,phone_number,city)
@id = id
@full_name = full_name
@phone_number = phone_number
@city = city
end
end