Class: Restaurant

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(restaurant) ⇒ Restaurant

Returns a new instance of Restaurant.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/restaurant.rb', line 6

def initialize(restaurant)
  location = restaurant.location
  coordinate = location.coordinate
  [restaurant, location, coordinate].each do |instance|
    instance.instance_variables.each do |variable|
      instance_has = instance.instance_variable_defined?(variable)
      self_has = self.instance_variables.find(variable)
      if instance_has && self_has
        if variable.to_s == "@categories"
          categories = instance.categories
            .map {|category| Category.find_by_title(category[0])}
            .compact
          @categories = categories
          categories.each {|category| category.restaurants << self}
        else
          self.instance_variable_set(variable, instance.instance_variable_get(variable))
        end
      end
    end
  end
  @@all << self
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



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

def address
  @address
end

#categoriesObject

Returns the value of attribute categories.



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

def categories
  @categories
end

#cityObject

Returns the value of attribute city.



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

def city
  @city
end

#country_codeObject

Returns the value of attribute country_code.



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

def country_code
  @country_code
end

#cross_streetsObject

Returns the value of attribute cross_streets.



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

def cross_streets
  @cross_streets
end

#display_addressObject

Returns the value of attribute display_address.



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

def display_address
  @display_address
end

#display_phoneObject

Returns the value of attribute display_phone.



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

def display_phone
  @display_phone
end

#distanceObject

Returns the value of attribute distance.



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

def distance
  @distance
end

#eat24_urlObject

Returns the value of attribute eat24_url.



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

def eat24_url
  @eat24_url
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#image_urlObject

Returns the value of attribute image_url.



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

def image_url
  @image_url
end

#is_claimedObject

Returns the value of attribute is_claimed.



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

def is_claimed
  @is_claimed
end

#is_closedObject

Returns the value of attribute is_closed.



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

def is_closed
  @is_closed
end

#latitudeObject

Returns the value of attribute latitude.



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

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



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

def longitude
  @longitude
end

Returns the value of attribute menu_date_updated.



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

def menu_date_updated
  @menu_date_updated
end

Returns the value of attribute menu_provider.



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

def menu_provider
  @menu_provider
end

#mobile_urlObject

Returns the value of attribute mobile_url.



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

def mobile_url
  @mobile_url
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#neighborhoodsObject

Returns the value of attribute neighborhoods.



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

def neighborhoods
  @neighborhoods
end

#phoneObject

Returns the value of attribute phone.



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

def phone
  @phone
end

#postal_codeObject

Returns the value of attribute postal_code.



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

def postal_code
  @postal_code
end

#ratingObject

Returns the value of attribute rating.



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

def rating
  @rating
end

#rating_img_urlObject

Returns the value of attribute rating_img_url.



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

def rating_img_url
  @rating_img_url
end

#rating_img_url_largeObject

Returns the value of attribute rating_img_url_large.



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

def rating_img_url_large
  @rating_img_url_large
end

#rating_img_url_smallObject

Returns the value of attribute rating_img_url_small.



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

def rating_img_url_small
  @rating_img_url_small
end

#reservation_urlObject

Returns the value of attribute reservation_url.



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

def reservation_url
  @reservation_url
end

#review_countObject

Returns the value of attribute review_count.



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

def review_count
  @review_count
end

#snippet_image_urlObject

Returns the value of attribute snippet_image_url.



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

def snippet_image_url
  @snippet_image_url
end

#snippet_textObject

Returns the value of attribute snippet_text.



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

def snippet_text
  @snippet_text
end

#state_codeObject

Returns the value of attribute state_code.



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

def state_code
  @state_code
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.allObject



29
30
31
# File 'lib/restaurant.rb', line 29

def self.all
  @@all
end