Class: Gcloud::Logging::Metric::List
- Inherits:
-
Array
- Object
- Array
- Gcloud::Logging::Metric::List
- Defined in:
- lib/gcloud/logging/metric/list.rb
Overview
Metric::List is a special case Array with additional values.
Instance Attribute Summary collapse
-
#token ⇒ Object
If not empty, indicates that there are more records that match the request and this value should be passed to continue.
Class Method Summary collapse
-
.from_grpc(grpc_list, service) ⇒ Object
Google::Logging::V2::ListLogMetricsResponse object.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(arr = []) ⇒ List
constructor
A new instance of List.
-
#next ⇒ Object
Retrieve the next page of metrics.
-
#next? ⇒ Boolean
Whether there is a next page of metrics.
Constructor Details
#initialize(arr = []) ⇒ List
Returns a new instance of List.
31 32 33 |
# File 'lib/gcloud/logging/metric/list.rb', line 31 def initialize arr = [] super arr end |
Instance Attribute Details
#token ⇒ Object
If not empty, indicates that there are more records that match the request and this value should be passed to continue.
27 28 29 |
# File 'lib/gcloud/logging/metric/list.rb', line 27 def token @token end |
Class Method Details
.from_grpc(grpc_list, service) ⇒ Object
Google::Logging::V2::ListLogMetricsResponse object.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/gcloud/logging/metric/list.rb', line 75 def self.from_grpc grpc_list, service metrics = new(Array(grpc_list.metrics).map do |grpc_metric| Metric.from_grpc grpc_metric, service end) token = grpc_list.next_page_token token = nil if token == "" metrics.instance_variable_set "@token", token metrics.instance_variable_set "@service", service metrics end |
Instance Method Details
#all ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/gcloud/logging/metric/list.rb', line 63 def all while next? next_records = self.next push(*next_records) self.token = next_records.token end self end |
#next ⇒ Object
Retrieve the next page of metrics.
43 44 45 46 47 48 49 50 |
# File 'lib/gcloud/logging/metric/list.rb', line 43 def next return nil unless next? ensure_service! grpc = @service.list_metrics token: token self.class.from_grpc grpc, @service rescue GRPC::BadStatus => e raise Gcloud::Error.from_error(e) end |
#next? ⇒ Boolean
Whether there is a next page of metrics.
37 38 39 |
# File 'lib/gcloud/logging/metric/list.rb', line 37 def next? !token.nil? end |