class CoffeeHunt::CoffeeShop

Attributes

location[RW]
name[RW]
phone[RW]
price[RW]
rating[RW]

Public Class Methods

all() click to toggle source
# File lib/Coffee_Hunt/coffee_shop.rb, line 8
def self.all #access to the @@all array aka my getter method
  @@all
end
create_from_results(location_results) click to toggle source
# File lib/Coffee_Hunt/coffee_shop.rb, line 22
def self.create_from_results(location_results) #returns the collection of coffee shops
  location_results.map do |coffee_shop_hash|
    self.new(coffee_shop_hash)
  end
end
find_by_number(n) click to toggle source
# File lib/Coffee_Hunt/coffee_shop.rb, line 28
def self.find_by_number(n) # will return the coffee shop object
  @@all[n.to_i-1]
end
load_by_location(location) click to toggle source
# File lib/Coffee_Hunt/coffee_shop.rb, line 12
def self.load_by_location(location) # returns my array of coffee shops
  location_results = API.yelp_search("coffee shop", location) 
  if location_results != nil 
  @@all = self.create_from_results(location_results)
  else 
    @@all = []
  end
  # binding.pry
end
new(attributes={}) click to toggle source
# File lib/Coffee_Hunt/coffee_shop.rb, line 43
def initialize(attributes={})
  # binding.pry
  attributes.each do |attribute_name,attribute_value|
    if self.respond_to?("#{attribute_name}=")
      self.send("#{attribute_name}=", attribute_value)
    end
  end
end

Public Instance Methods

details() click to toggle source
# File lib/Coffee_Hunt/coffee_shop.rb, line 32
    def details #will display the information about the coffee shops
      <<-HEREDOC
#{self.name.colorize(:yellow)}
#{self.location["display_address"].join("\n")}
#{self.phone}
Rating:#{self.rating}    
      HEREDOC
    end