Ruby Build an Address Book in Ruby Input and Output Searching the Address Book

Michael Cook
Michael Cook
3,425 Points

I don't know how to pass this challenge in Ruby "Building an Address Book"

Hi, so in this challenge task (I've already completed part one) it wants to to call 3 methods via one argument (It states that the methods exist outside the block of code I have), and I'm not exactly sure how to do that in this case maybe I forgot something along the way but I tried some different ways of doing so and all I got was either "Oops! Task One isn't responding!" (I don't think it says that but something similar) or "Bummer, try again!".

Sadly it doesn't help me when it just tells me "Bummer! Try Again!" or something similar. The code below is what is ONLY required to pass the first challenge. I just seem to get lost easy without the other part of the program that isn't visible to me.

Here is the question it's asking me.

"In the search method, call the find_by_name, find_by_address, and find_by_phone_number methods with the argument passed in to the search method. You can assume that these methods are already defined and do not have to write them."

All help is appreciated!

address_book.rb
class AddressBook
  def search(arg1)


  end
end

address_book = AddressBook.new

2 Answers

Jean Malan
Jean Malan
10,781 Points

Okay so there are three methods that exist namely: find_by_name, find_by_address, and find_by_phone_number methods.

Within the search() method you can call upon other methods to pass in the argument. So it will look like class

AddressBook
 def search( address_book1)
     find_by_name( address_book1)
     find_by_address ( address_book1)
     find_by_phone_number ( address_book1)

  end
end

address_book1 = AddressBook.new

That should work. But don't let the "Bummer" comments frustrate you. You need to try until you have done everything - including reading external material. That being said - Hope this works

Michael Cook
Michael Cook
3,425 Points

Thanks! That explained a lot! I managed to pass the task!