class KnoxRestaurants::Restaurant

Attributes

address[RW]
cuisine[RW]
name[RW]
phone_number[RW]
price[RW]
rating[RW]
reviews[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/Knox_Restaurants/restaurant.rb, line 22
def self.all
    @@all
end
get_cuisine_restaurants(num) click to toggle source
# File lib/Knox_Restaurants/restaurant.rb, line 31
def self.get_cuisine_restaurants(num)
    #compares the user input as an integer to find the cuisine that matches the Restaurant instance
  cuisine = self.get_cuisines[num-1]
  rest = self.all.select {|r| r.cuisine.include?(cuisine)}
end
get_cuisines() click to toggle source
# File lib/Knox_Restaurants/restaurant.rb, line 26
def self.get_cuisines 
    #displays a list of cuisines with no duplicates
    self.all.collect{|r| r.cuisine}.flatten.uniq
end
new(restaurant_hash) click to toggle source

a restaurant has a name, a list of cuisines, an address, a phone number website, rating, price range, and reviews

# File lib/Knox_Restaurants/restaurant.rb, line 9
def initialize(restaurant_hash) 
    #instantiates a Restaurant object with a hash of attributes belong to each instance
    @name = restaurant_hash[:name]
    @phone_number = restaurant_hash[:phone_number]
    @cuisine = restaurant_hash[:cuisine]
    @address = restaurant_hash[:address]
    @url = restaurant_hash[:url]
    @rating = restaurant_hash[:rating]
    @price = restaurant_hash[:price]
    @reviews = restaurant_hash[:reviews]
    @@all << self
end