Class: Algolia::Index::IndexBrowser
- Inherits:
-
Object
- Object
- Algolia::Index::IndexBrowser
- Defined in:
- lib/algolia/index.rb
Instance Method Summary collapse
- #browse(&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.
145 146 147 148 149 150 |
# File 'lib/algolia/index.rb', line 145 def initialize(client, name, params) @client = client @name = name @params = params @cursor = params[:cursor] || params['cursor'] || nil end |
Instance Method Details
#browse(&block) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/algolia/index.rb', line 152 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 |