Class: Restaurant

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, url = nil, location = nil, position = nil) ⇒ Restaurant

Returns a new instance of Restaurant.



7
8
9
10
11
12
13
# File 'lib/worlds_best_restaurants/restaurant.rb', line 7

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_dishObject

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

#contactObject

Returns the value of attribute contact.



3
4
5
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3

def contact
  @contact
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3

def description
  @description
end

#food_styleObject

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_chefObject

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

#locationObject

Returns the value of attribute location.



3
4
5
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3

def location
  @location
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3

def name
  @name
end

#positionObject

Returns the value of attribute position.



3
4
5
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3

def position
  @position
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/worlds_best_restaurants/restaurant.rb', line 3

def url
  @url
end

#website_urlObject

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

.allObject



15
16
17
# File 'lib/worlds_best_restaurants/restaurant.rb', line 15

def self.all
  @@all
end

.find(id) ⇒ Object



19
20
21
# File 'lib/worlds_best_restaurants/restaurant.rb', line 19

def self.find(id)
  self.all[id-1]
end

Instance Method Details

#docObject



47
48
49
# File 'lib/worlds_best_restaurants/restaurant.rb', line 47

def doc 
  @doc ||= Nokogiri::HTML(open(self.url))
end