Class: Yummly::Api
- Inherits:
-
Object
- Object
- Yummly::Api
- Defined in:
- lib/yummly/api.rb
Overview
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.
Class Method Summary collapse
-
.find(id) ⇒ Yummly::Recipe
Retrieves a single recipe.
-
.search(terms, params = {}) ⇒ Array
Searches for recipes that match the supplied search terms.
Class Method Details
.find(id) ⇒ Yummly::Recipe
Retrieves a single recipe.
17 18 19 20 |
# File 'lib/yummly/api.rb', line 17 def self.find(id) recipe_json = Yummly::Connection.get("recipe/#{id}") Yummly::Recipe.new(recipe_json) end |
.search(terms, params = {}) ⇒ Array
Searches for recipes that match the supplied search terms.
29 30 31 32 33 |
# File 'lib/yummly/api.rb', line 29 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 |