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

Erkam #3

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
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions .idea/odev-01ruby.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

337 changes: 337 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
source 'https://rubygems.org'

gem 'minitest'
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
23 changes: 20 additions & 3 deletions address_book.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
require 'csv'
require './person.rb'

class AddressBook
def initialize(csv_path)

attr_accessor :people

def initialize(csv_path)
@people = []
CSV.foreach(csv_path) do |row|
people.push(Person.new(row[0], row[1], row[2],row[3]))
end
end

def print_people

people.each do |person|
puts "#{person.id}, #{person.full_name}, #{person.phone_number}, #{person.city}"
end
end

def search_person(person_name)

people.each do |person|
if person.full_name.to_s.include? person_name
puts "#{person.id}, #{person.full_name}, #{person.phone_number}, #{person.city}"
return
end
end
puts "#{person_name} bulunamadı."
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("Roy")
9 changes: 9 additions & 0 deletions person.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
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