Class: Algolia::Index::IndexBrowser
- Inherits:
-
Object
- Object
- Algolia::Index::IndexBrowser
- Defined in:
- lib/algolia/index.rb
Instance Method Summary collapse
- #browse(request_options = {}, &block) ⇒ Object
-
#initialize(client, name, params) ⇒ IndexBrowser
constructor
A new instance of IndexBrowser.
Constructor Details
#initialize(client, name, params) ⇒ IndexBrowser
Returns a new instance of IndexBrowser.
168 169 170 171 172 173 |
# File 'lib/algolia/index.rb', line 168 def initialize(client, name, params) @client = client @name = name @params = params @cursor = params[:cursor] || params['cursor'] || nil end |
Instance Method Details
#browse(request_options = {}, &block) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/algolia/index.rb', line 175 def browse( = {}, &block) loop do answer = @client.get(Protocol.browse_uri(@name, @params.merge({ :cursor => @cursor })), :read, ) answer['hits'].each do |hit| if block.arity == 2 yield hit, @cursor else yield hit end end @cursor = answer['cursor'] break if @cursor.nil? end end |