Class: BOSSMan::ResultSet
Class Method Summary
collapse
Instance Method Summary
collapse
#set_parameter, #to_json, #to_yaml
Constructor Details
#initialize(response) ⇒ ResultSet
Returns a new instance of ResultSet.
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/bossman/resultset.rb', line 4
def initialize(response)
@response = response
@response["ysearchresponse"].each do |key, value|
if key.include? "resultset_spell"
set_parameter("suggestion", @response["ysearchresponse"]["resultset_spell"][0]["suggestion"])
elsif key.include? "resultset"
results = Array.new
response["ysearchresponse"][key].each { |result|
begin
result = Result.new(result)
rescue
next
else
results << result
end
}
set_parameter("results", results)
else
set_parameter(key, value)
end
end
end
|
Class Method Details
._load(string) ⇒ Object
36
37
38
|
# File 'lib/bossman/resultset.rb', line 36
def self._load(string)
ResultSet.new(ActiveSupport::JSON.decode(string))
end
|
Instance Method Details
#_dump(level) ⇒ Object
32
33
34
|
# File 'lib/bossman/resultset.rb', line 32
def _dump(level)
@response.to_json
end
|
#to_xml ⇒ Object
Also known as:
to_s
28
29
30
|
# File 'lib/bossman/resultset.rb', line 28
def to_xml
@response['ysearchresponse'].to_xml(:root => 'resultset')
end
|