Class: Yummly::SearchResult

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/yummly/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ SearchResult

Returns a new instance of SearchResult.



12
13
14
# File 'lib/yummly/search_result.rb', line 12

def initialize(response)
  @response = response
end

Instance Attribute Details

#max_resultObject

Returns the value of attribute max_result.



10
11
12
# File 'lib/yummly/search_result.rb', line 10

def max_result
  @max_result
end

#paramsObject

Returns the value of attribute params.



10
11
12
# File 'lib/yummly/search_result.rb', line 10

def params
  @params
end

#responseObject

Returns the value of attribute response.



10
11
12
# File 'lib/yummly/search_result.rb', line 10

def response
  @response
end

#startObject

Returns the value of attribute start.



10
11
12
# File 'lib/yummly/search_result.rb', line 10

def start
  @start
end

Instance Method Details

#attributionObject



33
34
35
# File 'lib/yummly/search_result.rb', line 33

def attribution
  Yummly::Attribution.new(response["attribution"])
end

#criteriaObject



37
38
39
# File 'lib/yummly/search_result.rb', line 37

def criteria
  response["criteria"]
end

#each(&block) ⇒ Object



16
17
18
# File 'lib/yummly/search_result.rb', line 16

def each(&block)
  recipes.each(&block)
end

#matchesObject



24
25
26
# File 'lib/yummly/search_result.rb', line 24

def matches
  response["matches"] || []
end

#recipesObject



20
21
22
# File 'lib/yummly/search_result.rb', line 20

def recipes
  @recipes ||= matches.collect { |recipe_json| Yummly::Recipe.new(recipe_json) }
end

#total_match_countObject Also known as: total



28
29
30
# File 'lib/yummly/search_result.rb', line 28

def total_match_count
  response["totalMatchCount"]
end