Class: Yummly::SearchResult
- Inherits:
-
Object
- Object
- Yummly::SearchResult
- Includes:
- Enumerable
- Defined in:
- lib/yummly/search_result.rb
Instance Attribute Summary collapse
-
#max_result ⇒ Object
Returns the value of attribute max_result.
-
#params ⇒ Object
Returns the value of attribute params.
-
#response ⇒ Object
Returns the value of attribute response.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
- #attribution ⇒ Object
- #criteria ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(response) ⇒ SearchResult
constructor
A new instance of SearchResult.
- #matches ⇒ Object
- #recipes ⇒ Object
- #total_match_count ⇒ Object (also: #total)
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_result ⇒ Object
Returns the value of attribute max_result.
10 11 12 |
# File 'lib/yummly/search_result.rb', line 10 def max_result @max_result end |
#params ⇒ Object
Returns the value of attribute params.
10 11 12 |
# File 'lib/yummly/search_result.rb', line 10 def params @params end |
#response ⇒ Object
Returns the value of attribute response.
10 11 12 |
# File 'lib/yummly/search_result.rb', line 10 def response @response end |
#start ⇒ Object
Returns the value of attribute start.
10 11 12 |
# File 'lib/yummly/search_result.rb', line 10 def start @start end |
Instance Method Details
#attribution ⇒ Object
33 34 35 |
# File 'lib/yummly/search_result.rb', line 33 def attribution Yummly::Attribution.new(response["attribution"]) end |
#criteria ⇒ Object
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 |
#matches ⇒ Object
24 25 26 |
# File 'lib/yummly/search_result.rb', line 24 def matches response["matches"] || [] end |
#recipes ⇒ Object
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_count ⇒ Object Also known as: total
28 29 30 |
# File 'lib/yummly/search_result.rb', line 28 def total_match_count response["totalMatchCount"] end |