Class: YumConnector
- Inherits:
-
Object
- Object
- YumConnector
- Defined in:
- lib/yum_connector.rb
Overview
Handles connection using Requests and provides the results to client
Class Method Summary collapse
-
.food_by_id(food_id) ⇒ Food
Provides the food from Yummly by its id.
-
.search(parameters, xp) ⇒ Food
Searches the food according to search parameters from command line.
Class Method Details
.food_by_id(food_id) ⇒ Food
Provides the food from Yummly by its id
21 22 23 24 25 |
# File 'lib/yum_connector.rb', line 21 def self.food_by_id(food_id) return food_id if food_id.eql? 'Empty plate' food_json = JSON.parse Request.get_recipe food_id Food.new food_json end |
.search(parameters, xp) ⇒ Food
Searches the food according to search parameters from command line
8 9 10 11 12 13 14 15 |
# File 'lib/yum_connector.rb', line 8 def self.search(parameters, xp) result = Request.search parameters, xp return nil if result.nil? searched_result = JSON.parse result id = Parser.food_id searched_result['matches'].sample food_json = JSON.parse Request.get_recipe id Food.new food_json end |