Skip to content

Instantly share code, notes, and snippets.

@Lvtran1987
Created December 19, 2015 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lvtran1987/d6322db131c037045184 to your computer and use it in GitHub Desktop.
Save Lvtran1987/d6322db131c037045184 to your computer and use it in GitHub Desktop.
def find_by_address(query)
results = []
search = query.downcase
contacts.each do |contact|
contact.addresses.each do |address|
if address.to_s('long').downcase.include?(search)
results.push(contact) unless results.include?(contact)
end
end
end
print_results("Address search results (#{search})", results) # Is print_results here in the public domain?
end
end
address_book = AddressBook.new
loi = Contact.new
loi.fname = "Loi"
loi.mname = "Van"
loi.lname = "Tran"
loi.add_phone_number("Home", "850-123-1234")
loi.add_phone_number("Work", "123-456-1234")
loi.add_address("Mansion", "First in the world lane two shot", "", "Miami", "FL", "12345")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment