Class: Rospatent::SearchResult
- Inherits:
-
Object
- Object
- Rospatent::SearchResult
- Defined in:
- lib/rospatent/search.rb
Overview
Search result class to handle API responses
Instance Attribute Summary collapse
-
#available ⇒ Object
readonly
Returns the value of attribute available.
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#any? ⇒ Boolean
Check if the search has any results.
-
#count ⇒ Integer
Return the number of hits in the current response.
-
#initialize(response) ⇒ SearchResult
constructor
Initialize a search result from API response.
Constructor Details
#initialize(response) ⇒ SearchResult
Initialize a search result from API response
12 13 14 15 16 17 |
# File 'lib/rospatent/search.rb', line 12 def initialize(response) @raw_response = response @total = response["total"] @available = response["available"] @hits = response["hits"] || [] end |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
8 9 10 |
# File 'lib/rospatent/search.rb', line 8 def available @available end |
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
8 9 10 |
# File 'lib/rospatent/search.rb', line 8 def hits @hits end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
8 9 10 |
# File 'lib/rospatent/search.rb', line 8 def raw_response @raw_response end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
8 9 10 |
# File 'lib/rospatent/search.rb', line 8 def total @total end |
Instance Method Details
#any? ⇒ Boolean
Check if the search has any results
21 |
# File 'lib/rospatent/search.rb', line 21 def any? = !@hits.empty? |
#count ⇒ Integer
Return the number of hits in the current response
25 |
# File 'lib/rospatent/search.rb', line 25 def count = @hits.count |