Writing ruby simple restaurant finder

Hello,
I just finished the Ruby essential Training course
I want to know how to write a very simple script for Restaurant Finder
using the command line only if possible?

Features needed:
User asked to input 1- restaurant name 2- restaurant type 3- restaurant
average price

user gets response list of the restaurants (nothing will be saved on
file) only in the memory during the session.

also how can i let the user shows the list of added restaurants?

I want to make it as simple as possible so i can understand the language
in a way that i missed it by the Lynda.com instructor.
Once this instructor reached the actual script building, he started
modifying it and write lots of speedy code that confused me and made me
almost thing like it is PHP not Ruby Video training I’m watching.

I know how to create classes and methods and using array hashes etc…
Want basic simple start to try myself how to write simple programs
without using files to store anything

after that i will move to the next level.

Thanks.

Hi,

Well, you’ll obviously need some kind of database for the restaurants.
The easiest way is probably to save them in a file as CSV (“comma
separated values”). You can then use the CSV class from Ruby’s standard
library to process them:

http://ruby-doc.org/stdlib-1.9.2/libdoc/csv/rdoc/CSV.html

Processing means going through each row and checking if the values match
the search criteria.

You could also use a “real” database system like PostgreSQL. But that
would take quite some time to learn.

On 7/27/2012 3:06 PM, Jan E. wrote:

the search criteria.

You could also use a “real” database system like PostgreSQL. But that
would take quite some time to learn.

and you can take some approach about it like:
load from file to mem.
write data on one of these conditions:
exit
write\save command
every 10 or other writes to db.

these will allow you lower disk access but has the risk of loosing data.

Regards,
Eliezer

Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs