Class: Google::Cloud::Trace::ResultSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/google/cloud/trace/result_set.rb

Overview

ResultSet represents the results of a list_traces request. It is an enumerable of the traces found, plus information about the request and a token to get the next page of results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_timeTime? (readonly)

The end_time query parameter.

Returns:

  • (Time, nil)


120
121
122
# File 'lib/google/cloud/trace/result_set.rb', line 120

def end_time
  @end_time
end

#filterString? (readonly)

The filter query parameter.

Returns:

  • (String, nil)


127
128
129
# File 'lib/google/cloud/trace/result_set.rb', line 127

def filter
  @filter
end

#next_page_tokenString? (readonly)

The token to pass to list_traces to get the next page, or nil if this is the last page.

Returns:

  • (String, nil)


92
93
94
# File 'lib/google/cloud/trace/result_set.rb', line 92

def next_page_token
  @next_page_token
end

#order_byString? (readonly)

The order_by query parameter.

Returns:

  • (String, nil)


134
135
136
# File 'lib/google/cloud/trace/result_set.rb', line 134

def order_by
  @order_by
end

#page_sizeInteger? (readonly)

The page_size query parameter.

Returns:

  • (Integer, nil)


106
107
108
# File 'lib/google/cloud/trace/result_set.rb', line 106

def page_size
  @page_size
end

#page_tokenString? (readonly)

The page token used to obtain this page of results.

Returns:

  • (String, nil)


141
142
143
# File 'lib/google/cloud/trace/result_set.rb', line 141

def page_token
  @page_token
end

#projectString (readonly)

The project ID string.

Returns:

  • (String)


84
85
86
# File 'lib/google/cloud/trace/result_set.rb', line 84

def project
  @project
end

#start_timeTime? (readonly)

The start_time query parameter.

Returns:

  • (Time, nil)


113
114
115
# File 'lib/google/cloud/trace/result_set.rb', line 113

def start_time
  @start_time
end

#viewSymbol? (readonly)

The view query parameter.

Returns:

  • (Symbol, nil)


99
100
101
# File 'lib/google/cloud/trace/result_set.rb', line 99

def view
  @view
end

Instance Method Details

#each(&block) ⇒ Object

An each method that supports the Enumerable module. Iterates over the results and yields each, as a TraceRecord object, to the given block. If no block is provided, returns an Enumerator.



61
62
63
# File 'lib/google/cloud/trace/result_set.rb', line 61

def each &block
  @results.each(&block)
end

#next_pageGoogle::Cloud::Trace::ResultSet

Queries the service for the next page of results and returns a new ResultSet for that page. Returns nil if there are no more results.



158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/google/cloud/trace/result_set.rb', line 158

def next_page
  return nil unless results_pending?
  service.list_traces \
    project,
    start_time,
    end_time,
    filter: filter,
    order_by: order_by,
    view: view,
    page_size: page_size,
    page_token: next_page_token
end

#results_pending?Boolean

Returns true if at least one more page of results can be retrieved.

Returns:

  • (Boolean)


148
149
150
# File 'lib/google/cloud/trace/result_set.rb', line 148

def results_pending?
  !next_page_token.nil?
end

#sizeInteger

Returns the number of traces in this page of results.

Returns:

  • (Integer)


70
71
72
# File 'lib/google/cloud/trace/result_set.rb', line 70

def size
  @results.size
end