Class: BOSSMan::ResultSet
- Inherits:
-
BaseValueObject
- Object
- BaseValueObject
- BOSSMan::ResultSet
- Defined in:
- lib/bossman/resultset.rb
Class Method Summary collapse
Instance Method Summary collapse
- #_dump(level) ⇒ Object
-
#initialize(response) ⇒ ResultSet
constructor
A new instance of ResultSet.
- #to_xml ⇒ Object (also: #to_s)
Methods inherited from BaseValueObject
#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 |
# 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| results << Result.new(result) } set_parameter("results", results) else set_parameter(key, value) end end end |
Class Method Details
Instance Method Details
#_dump(level) ⇒ Object
24 25 26 |
# File 'lib/bossman/resultset.rb', line 24 def _dump(level) @response.to_json end |
#to_xml ⇒ Object Also known as: to_s
20 21 22 |
# File 'lib/bossman/resultset.rb', line 20 def to_xml @response['ysearchresponse'].to_xml(:root => 'resultset') end |