Sha256: ef58dd27abb37fe16d70c93bf79d4ccd1dbad47820d3eb21c072c2306356b3a9
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
# This class is the primary mechanism to execute Yummly API calls. # # Currently Yummly only has two public API calls: one for searching recipes and the other to retrieve a specific recipe. # # @example # Yummly::Api.find('French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364') # @example # Yummly::Api.search('Onion soup') class Yummly::Api # Retrieves a single recipe. # # @param [String] id The yummly recipe identifier. # @return [Yummly::Recipe] a instance of a recipe object # @example # recipe = Yummly::Api.find('French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364') def self.find(id) recipe_json = Yummly::Connection.get("recipe/#{id}") Yummly::Recipe.new(recipe_json) end # Searches for recipes that match the supplied search terms. # # @param [String] terms A string of terms used to search API # @param [Hash] params Additional options to pass to the search API # @return [Array] a collection of recipe objects # @example # recipes = Yummly::Api.search('Onion soup') def self.search(terms, params = {}) params[:q] = terms unless params.has_key?(:q) result = Yummly::Connection.get(:recipes, params) result["matches"].collect { |recipe_json| Yummly::Recipe.new(recipe_json) } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yummly-0.0.3 | lib/yummly/api.rb |
yummly-0.0.2 | lib/yummly/api.rb |
yummly-0.0.1 | lib/yummly/api.rb |