Class: EsHttpClient::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/es_http_client/page.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/es_http_client/page.rb', line 17

def has_entries?
  @body['entries'] && @body['entries'].length > 0
end

#lastObject



9
10
11
# File 'lib/es_http_client/page.rb', line 9

def last
  find_link('last')
end

#previousObject



13
14
15
# File 'lib/es_http_client/page.rb', line 13

def previous
  find_link('previous')
end