Class: SearchResponse
- Defined in:
- lib/dto/search/search_response.rb
Overview
Class SearchResponse represents server response on search
Search API request. Server response is sent to initializer which creates object with attributes success
, numResults
, execTimeMs
, results
accessible via getters:
-
success
-
num_results
-
numResults
-
execTimeMs
-
exec_time_ms
-
results
Examples:
response = SearchResponse.new("success" => "true", "numResults" => 0, "execTimeMs" => 100, "results" => [])
response.category # => "VAUT"
response.numResults # => 0
response.num_results # => 0
response.execTimeMs # => 100
response.exec_time_ms # => 100
response.results # => []
Instance Attribute Summary collapse
-
#execTimeMs ⇒ Object
Returns the value of attribute execTimeMs.
-
#numResults ⇒ Object
Returns the value of attribute numResults.
-
#results ⇒ Object
Returns the value of attribute results.
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ SearchResponse
constructor
Initializer receives hash as a parameter and fills object fields from it.
Methods inherited from Struct
Constructor Details
#initialize(hash = {}) ⇒ SearchResponse
Initializer receives hash as a parameter and fills object fields from it. results
field is filled with array of Posting objects.
32 33 34 35 36 |
# File 'lib/dto/search/search_response.rb', line 32 def initialize(hash = {}) hash.each do |key, value| self.send("#{key}=".to_sym, key == 'results' ? value.collect {|item| Posting.new(item)} : value ) end end |
Instance Attribute Details
#execTimeMs ⇒ Object
Returns the value of attribute execTimeMs
21 22 23 |
# File 'lib/dto/search/search_response.rb', line 21 def execTimeMs @execTimeMs end |
#numResults ⇒ Object
Returns the value of attribute numResults
21 22 23 |
# File 'lib/dto/search/search_response.rb', line 21 def numResults @numResults end |
#results ⇒ Object
Returns the value of attribute results
21 22 23 |
# File 'lib/dto/search/search_response.rb', line 21 def results @results end |
#success ⇒ Object
Returns the value of attribute success
21 22 23 |
# File 'lib/dto/search/search_response.rb', line 21 def success @success end |