Class: GuardianSearcher::SearchResult
- Inherits:
-
Object
- Object
- GuardianSearcher::SearchResult
- Defined in:
- lib/guardian_searcher/search_result.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(current_page: nil, results: nil, page_size: nil, pages: nil, start: nil) ⇒ SearchResult
constructor
A new instance of SearchResult.
Constructor Details
#initialize(current_page: nil, results: nil, page_size: nil, pages: nil, start: nil) ⇒ SearchResult
Returns a new instance of SearchResult.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/guardian_searcher/search_result.rb', line 9 def initialize( current_page: nil, results: nil, page_size: nil, pages: nil, start: nil ) @current_page = current_page @results = results @page_size = page_size @pages = pages @start = start end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
7 8 9 |
# File 'lib/guardian_searcher/search_result.rb', line 7 def current_page @current_page end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
7 8 9 |
# File 'lib/guardian_searcher/search_result.rb', line 7 def page_size @page_size end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
7 8 9 |
# File 'lib/guardian_searcher/search_result.rb', line 7 def pages @pages end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
7 8 9 |
# File 'lib/guardian_searcher/search_result.rb', line 7 def results @results end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
7 8 9 |
# File 'lib/guardian_searcher/search_result.rb', line 7 def start @start end |
Class Method Details
.parse_results(body: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/guardian_searcher/search_result.rb', line 24 def self.parse_results(body: nil) return unless body body = JSON.parse(body) response = body["response"] GuardianSearcher::SearchResult.new( current_page: response["currentPage"], results: response["results"], page_size: response["pageSize"], pages: response["pages"], start: response["startIndex"] ) end |