Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8292007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:19:13+00:00 2026-06-08T13:19:13+00:00

I just finished the Ruby essential Training course I want to know how to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:19:15+00:00Added an answer on June 8, 2026 at 1:19 pm

    I am a newbie in Ruby too, but this is my simple implementation:

     class Restaurant
      attr_accessor :name, :type, :avg_price
       def initialize(name, type, avg_price)
         @name = name
         @type = type
         @avg_price = Float(avg_price)
       end   
     end
    
     class RestaurantsList < Array
      def read_from_keyboard
        print "Restaurant name: "
        name = gets.chomp
        print "Restaurant type: "
        type = gets.chomp
        print "Restaurant average price: "
        avg_price = gets.chomp
        self << Restaurant.new( name, type, avg_price )
      end
      def print_list
        puts sprintf("%17s %15s %s", "Name |", "Type |", "Avg price |")
        self.each { |e|  puts sprintf("%15s |%14s |%10d |", e.name, e.type, e.avg_price)}    
      end
     end
    
    restaurants_list = RestaurantsList.new
    loop do
      print "1 - add restaurant, 2 - print list, 3 - exit : "
      answer = Integer(gets.chomp)
      case answer
      when 1
        restaurants_list.read_from_keyboard
      when 2
        restaurants_list.print_list
      when 3
        break    
      end    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have just finished my first web based application using Ruby on Rails. It was
I just finished upgrading from rails 2.3.5 to rails 3.2.6, I'm using ruby 1.8.7
I just finished this script it works well, but I am struggling to pass
We just finished implementing OAuth in our RoR application using the Twitter gem .
I just finished a script to import data from an XML file to MySQL,
I just finished chapter 10 of the Ruby on Rails Tutorial , adding the
Just finished a very long debug session. Please help me understand what root-cause/bad-practice caused
I just finished my website, using codeigniter, i uploaded the site to a bluehost
Just finished my project in Eclipse, using Sphinx for voice recognition. In eclipse the
I just finished taking an independent study course for CS282 - Computer Physics Simulation.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.