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(json) ⇒ SearchResult

Returns a new instance of SearchResult.



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

def initialize(json)
  @json = json
end

Instance Attribute Details

#jsonObject

Returns the value of attribute json.



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

def json
  @json
end

#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

#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(json["attribution"])
end

#criteriaObject



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

def criteria
  json["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
  json["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
  json["totalMatchCount"]
end