Class: KnoxRestaurants::Restaurant

Inherits:
Object
  • Object
show all
Defined in:
lib/Knox_Restaurants/restaurant.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(restaurant_hash) ⇒ Restaurant

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



9
10
11
12
13
14
15
16
17
18
19
20
# 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

Instance Attribute Details

#addressObject

Returns the value of attribute address.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def address
  @address
end

#cuisineObject

Returns the value of attribute cuisine.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def cuisine
  @cuisine
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def name
  @name
end

#phone_numberObject

Returns the value of attribute phone_number.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def phone_number
  @phone_number
end

#priceObject

Returns the value of attribute price.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def price
  @price
end

#ratingObject

Returns the value of attribute rating.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def rating
  @rating
end

#reviewsObject

Returns the value of attribute reviews.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def reviews
  @reviews
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/Knox_Restaurants/restaurant.rb', line 2

def url
  @url
end

Class Method Details

.allObject



22
23
24
# File 'lib/Knox_Restaurants/restaurant.rb', line 22

def self.all
    @@all
end

.get_cuisine_restaurants(num) ⇒ Object



31
32
33
34
35
# 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_cuisinesObject



26
27
28
29
# 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