Class: FatSecret::Food

Inherits:
Base
  • Object
show all
Defined in:
lib/fat_secret/food.rb

Class Method Summary collapse

Class Method Details

.get(food_id) ⇒ Object



31
32
33
# File 'lib/fat_secret/food.rb', line 31

def get(food_id)
  new FatSecret::Connection.get('food.get', food_id: food_id)['food']
end

.search(search_expression, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fat_secret/food.rb', line 18

def search(search_expression, options = {})
  results = Connection.get(
    'foods.search', default_search_options.
    merge({ search_expression: search_expression }).merge(options)
  )
  ResultsProxy.new(
    results['foods']['food'].map { |f| new(f) },
    results['foods']['max_results'],
    results['foods']['page_number'],
    results['foods']['total_results']
  )
end