Ruby Build an Address Book in Ruby Class Design Address Class: Part 1

Sarah A. Morrigan
Sarah A. Morrigan
14,299 Points

Can address book data be held on a separate file and called from either address.rb or contact.rb?

So here, in address.rb the data is held

home =
home.kind = "Home"
home.street_1 = "123 SE Main St." = "Portland"
home.state = "OR"
home.postal_code = "97214"

while all other data (names, phone numbers) are held in contact.rb.

It seems to make a better sense to create a separate file to save all the data away from the codes. Is it even possible (without getting into all the complicated mySQL stuff)?

2 Answers

You could probably write the data to a file, and read the data in from that file.

Check out for more information.

rowend rowend
rowend rowend
2,921 Points

Yes, you can write an array/any other structure like dict in data.rb file. Then import your file and file your objects with this structure.