class Grubber::Restaurant
Constants
- ATTRIBUTES
Public Class Methods
all(opts={})
click to toggle source
# File lib/grubber/restaurant.rb, line 16 def self.all(opts={}) q = opts[:term] || 'lunch' Client.new.search(q) end
new(opts={}) { |self| ... }
click to toggle source
# File lib/grubber/restaurant.rb, line 9 def initialize(opts={}) opts.each_pair do |k,v| self.instance_variable_set("@#{k}", v) end yield self end
parse(body)
click to toggle source
# File lib/grubber/restaurant.rb, line 34 def self.parse(body) JSON.parse(body)['businesses'].collect do |r| Restaurant.new do |n| ATTRIBUTES.map(&:to_s).each do |a| value = r[a] value = value.to_i if a == 'rating' n.send("#{a}=", value) end end end end
random(opts={})
click to toggle source
# File lib/grubber/restaurant.rb, line 21 def self.random(opts={}) all(opts).sample end
Public Instance Methods
address()
click to toggle source
# File lib/grubber/restaurant.rb, line 25 def address location['display_address'].first end
category()
click to toggle source
# File lib/grubber/restaurant.rb, line 29 def category cat = categories.first cat.is_a?(Array) ? cat.first : cat end