Class: EsHttpClient::Page
- Inherits:
-
Object
- Object
- EsHttpClient::Page
- Defined in:
- lib/es_http_client/page.rb
Instance Method Summary collapse
- #each_event(&block) ⇒ Object
- #has_entries? ⇒ Boolean
-
#initialize(body) ⇒ Page
constructor
A new instance of Page.
- #last ⇒ Object
- #previous ⇒ Object
Constructor Details
#initialize(body) ⇒ Page
Returns a new instance of Page.
5 6 7 |
# File 'lib/es_http_client/page.rb', line 5 def initialize(body) @body = body end |
Instance Method Details
#each_event(&block) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/es_http_client/page.rb', line 21 def each_event(&block) @body['entries'] .reverse! .map {|e| Event.load_from(e)} .compact .select {|e| e.type !~ /^\$/ } .each {|e| yield e } end |
#has_entries? ⇒ Boolean
17 18 19 |
# File 'lib/es_http_client/page.rb', line 17 def has_entries? @body['entries'] && @body['entries'].length > 0 end |
#last ⇒ Object
9 10 11 |
# File 'lib/es_http_client/page.rb', line 9 def last find_link('last') end |
#previous ⇒ Object
13 14 15 |
# File 'lib/es_http_client/page.rb', line 13 def previous find_link('previous') end |