Class: WorldsBestRestaurants::Restaurant
- Inherits:
-
Object
- Object
- WorldsBestRestaurants::Restaurant
- Defined in:
- lib/worlds_best_restaurants/restaurant.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#best_dish ⇒ Object
Returns the value of attribute best_dish.
-
#contact ⇒ Object
Returns the value of attribute contact.
-
#description ⇒ Object
Returns the value of attribute description.
-
#food_style ⇒ Object
Returns the value of attribute food_style.
-
#head_chef ⇒ Object
Returns the value of attribute head_chef.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#position ⇒ Object
Returns the value of attribute position.
-
#url ⇒ Object
Returns the value of attribute url.
-
#website_url ⇒ Object
Returns the value of attribute website_url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(name = nil, url = nil, location = nil, position = nil) ⇒ Restaurant
constructor
A new instance of Restaurant.
Constructor Details
#initialize(name = nil, url = nil, location = nil, position = nil) ⇒ Restaurant
Returns a new instance of Restaurant.
16 17 18 19 20 21 22 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 16 def initialize(name=nil, url=nil, location=nil, position=nil) @name = name @url = url @location = location @position = position @@all << self end |
Instance Attribute Details
#best_dish ⇒ Object
Returns the value of attribute best_dish.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def best_dish @best_dish end |
#contact ⇒ Object
Returns the value of attribute contact.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def contact @contact end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def description @description end |
#food_style ⇒ Object
Returns the value of attribute food_style.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def food_style @food_style end |
#head_chef ⇒ Object
Returns the value of attribute head_chef.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def head_chef @head_chef end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def name @name end |
#position ⇒ Object
Returns the value of attribute position.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def position @position end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def url @url end |
#website_url ⇒ Object
Returns the value of attribute website_url.
3 4 5 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3 def website_url @website_url end |
Class Method Details
.all ⇒ Object
24 25 26 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 24 def self.all @@all end |
.find(id) ⇒ Object
28 29 30 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 28 def self.find(id) self.all[id-1] end |
.new_from_index_page(r) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 7 def self.new_from_index_page(r) self.new( r.css("h2").text, "http://www.theworlds50best.com#{r.css("a").attribute("href").text}", r.css("h3").text, r.css(".position").text ) end |
Instance Method Details
#doc ⇒ Object
56 57 58 |
# File 'lib/worlds_best_restaurants/restaurant.rb', line 56 def doc @doc ||= Nokogiri::HTML(open(self.url)) end |