Class: KnoxRestaurants::Restaurant
- Inherits:
-
Object
- Object
- KnoxRestaurants::Restaurant
- Defined in:
- lib/Knox_Restaurants/restaurant.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#cuisine ⇒ Object
Returns the value of attribute cuisine.
-
#name ⇒ Object
Returns the value of attribute name.
-
#phone_number ⇒ Object
Returns the value of attribute phone_number.
-
#price ⇒ Object
Returns the value of attribute price.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#reviews ⇒ Object
Returns the value of attribute reviews.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(restaurant_hash) ⇒ Restaurant
constructor
a restaurant has a name, a list of cuisines, an address, a phone number website, rating, price range, and reviews.
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
#address ⇒ Object
Returns the value of attribute address.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def address @address end |
#cuisine ⇒ Object
Returns the value of attribute cuisine.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def cuisine @cuisine end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def name @name end |
#phone_number ⇒ Object
Returns the value of attribute phone_number.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def phone_number @phone_number end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def price @price end |
#rating ⇒ Object
Returns the value of attribute rating.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def @rating end |
#reviews ⇒ Object
Returns the value of attribute reviews.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def reviews @reviews end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/Knox_Restaurants/restaurant.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
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_cuisines ⇒ Object
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 |