google-cloud-vision 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/google-cloud-vision.rb +14 -26
- data/lib/google/cloud/vision.rb +108 -91
- data/lib/google/cloud/vision/annotate.rb +23 -25
- data/lib/google/cloud/vision/annotation.rb +58 -77
- data/lib/google/cloud/vision/annotation/entity.rb +24 -27
- data/lib/google/cloud/vision/annotation/face.rb +131 -148
- data/lib/google/cloud/vision/annotation/properties.rb +25 -27
- data/lib/google/cloud/vision/annotation/safe_search.rb +13 -14
- data/lib/google/cloud/vision/annotation/text.rb +27 -29
- data/lib/google/cloud/vision/annotation/vertex.rb +4 -5
- data/lib/google/cloud/vision/image.rb +39 -46
- data/lib/google/cloud/vision/location.rb +8 -9
- data/lib/google/cloud/vision/project.rb +31 -37
- data/lib/google/cloud/vision/service.rb +46 -21
- data/lib/google/cloud/vision/v1/image_annotator_api.rb +22 -6
- data/lib/google/cloud/vision/version.rb +1 -1
- metadata +63 -7
@@ -31,10 +31,9 @@ module Google
|
|
31
31
|
# See {Project#annotate}.
|
32
32
|
#
|
33
33
|
# @example
|
34
|
-
# require "google/cloud"
|
34
|
+
# require "google/cloud/vision"
|
35
35
|
#
|
36
|
-
#
|
37
|
-
# vision = gcloud.vision
|
36
|
+
# vision = Google::Cloud::Vision.new
|
38
37
|
#
|
39
38
|
# face_image = vision.image "path/to/face.jpg"
|
40
39
|
# landmark_image = vision.image "path/to/landmark.jpg"
|
@@ -74,7 +73,7 @@ module Google
|
|
74
73
|
# combined size of all images in a request. Reducing your file size can
|
75
74
|
# significantly improve throughput; however, be careful not to reduce
|
76
75
|
# image quality in the process. See [Best Practices - Image
|
77
|
-
# Sizing](https://cloud.google.com/vision/docs/
|
76
|
+
# Sizing](https://cloud.google.com/vision/docs/best-practices#image_sizing)
|
78
77
|
# for current file size limits.
|
79
78
|
#
|
80
79
|
# See {Project#annotate} for requests that do not involve multiple
|
@@ -118,10 +117,9 @@ module Google
|
|
118
117
|
# multiple images.
|
119
118
|
#
|
120
119
|
# @example
|
121
|
-
# require "google/cloud"
|
120
|
+
# require "google/cloud/vision"
|
122
121
|
#
|
123
|
-
#
|
124
|
-
# vision = gcloud.vision
|
122
|
+
# vision = Google::Cloud::Vision.new
|
125
123
|
#
|
126
124
|
# face_image = vision.image "path/to/face.jpg"
|
127
125
|
# landmark_image = vision.image "path/to/landmark.jpg"
|
@@ -159,10 +157,10 @@ module Google
|
|
159
157
|
|
160
158
|
Array(images).flatten.each do |img|
|
161
159
|
i = image(img)
|
162
|
-
@requests << Google::
|
163
|
-
image: i.
|
160
|
+
@requests << Google::Cloud::Vision::V1::AnnotateImageRequest.new(
|
161
|
+
image: i.to_grpc,
|
164
162
|
features: features,
|
165
|
-
|
163
|
+
image_context: i.context.to_grpc
|
166
164
|
)
|
167
165
|
end
|
168
166
|
end
|
@@ -176,18 +174,18 @@ module Google
|
|
176
174
|
faces, landmarks, logos, labels)
|
177
175
|
|
178
176
|
f = []
|
179
|
-
f << feature(
|
180
|
-
f << feature(
|
181
|
-
f << feature(
|
182
|
-
f << feature(
|
183
|
-
f << feature(
|
184
|
-
f << feature(
|
185
|
-
f << feature(
|
177
|
+
f << feature(:FACE_DETECTION, faces) unless faces.zero?
|
178
|
+
f << feature(:LANDMARK_DETECTION, landmarks) unless landmarks.zero?
|
179
|
+
f << feature(:LOGO_DETECTION, logos) unless logos.zero?
|
180
|
+
f << feature(:LABEL_DETECTION, labels) unless labels.zero?
|
181
|
+
f << feature(:TEXT_DETECTION, 1) if text
|
182
|
+
f << feature(:SAFE_SEARCH_DETECTION, 1) if safe_search
|
183
|
+
f << feature(:IMAGE_PROPERTIES, 1) if properties
|
186
184
|
f
|
187
185
|
end
|
188
186
|
|
189
187
|
def feature type, max_results
|
190
|
-
Google::
|
188
|
+
Google::Cloud::Vision::V1::Feature.new(
|
191
189
|
type: type, max_results: max_results)
|
192
190
|
end
|
193
191
|
|
@@ -200,15 +198,15 @@ module Google
|
|
200
198
|
|
201
199
|
def default_features
|
202
200
|
[
|
203
|
-
feature(
|
204
|
-
feature(
|
201
|
+
feature(:FACE_DETECTION, Google::Cloud::Vision.default_max_faces),
|
202
|
+
feature(:LANDMARK_DETECTION,
|
205
203
|
Google::Cloud::Vision.default_max_landmarks),
|
206
|
-
feature(
|
207
|
-
feature(
|
204
|
+
feature(:LOGO_DETECTION, Google::Cloud::Vision.default_max_logos),
|
205
|
+
feature(:LABEL_DETECTION,
|
208
206
|
Google::Cloud::Vision.default_max_labels),
|
209
|
-
feature(
|
210
|
-
feature(
|
211
|
-
feature(
|
207
|
+
feature(:TEXT_DETECTION, 1),
|
208
|
+
feature(:SAFE_SEARCH_DETECTION, 1),
|
209
|
+
feature(:IMAGE_PROPERTIES, 1)
|
212
210
|
]
|
213
211
|
end
|
214
212
|
|
@@ -30,10 +30,9 @@ module Google
|
|
30
30
|
# See {Project#annotate} and {Image}.
|
31
31
|
#
|
32
32
|
# @example
|
33
|
-
# require "google/cloud"
|
33
|
+
# require "google/cloud/vision"
|
34
34
|
#
|
35
|
-
#
|
36
|
-
# vision = gcloud.vision
|
35
|
+
# vision = Google::Cloud::Vision.new
|
37
36
|
# image = vision.image "path/to/face.jpg"
|
38
37
|
#
|
39
38
|
# annotation = vision.annotate image, faces: true, labels: true
|
@@ -43,13 +42,13 @@ module Google
|
|
43
42
|
#
|
44
43
|
class Annotation
|
45
44
|
##
|
46
|
-
# @private The AnnotateImageResponse
|
47
|
-
attr_accessor :
|
45
|
+
# @private The AnnotateImageResponse GRPC object.
|
46
|
+
attr_accessor :grpc
|
48
47
|
|
49
48
|
##
|
50
49
|
# @private Creates a new Annotation instance.
|
51
50
|
def initialize
|
52
|
-
@
|
51
|
+
@grpc = nil
|
53
52
|
end
|
54
53
|
|
55
54
|
##
|
@@ -58,10 +57,9 @@ module Google
|
|
58
57
|
# @return [Array<Face>]
|
59
58
|
#
|
60
59
|
# @example
|
61
|
-
# require "google/cloud"
|
60
|
+
# require "google/cloud/vision"
|
62
61
|
#
|
63
|
-
#
|
64
|
-
# vision = gcloud.vision
|
62
|
+
# vision = Google::Cloud::Vision.new
|
65
63
|
# image = vision.image "path/to/face.jpg"
|
66
64
|
#
|
67
65
|
# annotation = vision.annotate image, faces: true
|
@@ -69,8 +67,8 @@ module Google
|
|
69
67
|
# face = annotation.faces.first
|
70
68
|
#
|
71
69
|
def faces
|
72
|
-
@faces ||= Array(@
|
73
|
-
Face.
|
70
|
+
@faces ||= Array(@grpc.face_annotations).map do |fa|
|
71
|
+
Face.from_grpc fa
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
@@ -80,10 +78,9 @@ module Google
|
|
80
78
|
# @return [Face]
|
81
79
|
#
|
82
80
|
# @example
|
83
|
-
# require "google/cloud"
|
81
|
+
# require "google/cloud/vision"
|
84
82
|
#
|
85
|
-
#
|
86
|
-
# vision = gcloud.vision
|
83
|
+
# vision = Google::Cloud::Vision.new
|
87
84
|
# image = vision.image "path/to/face.jpg"
|
88
85
|
#
|
89
86
|
# annotation = vision.annotate image, faces: 1
|
@@ -99,10 +96,9 @@ module Google
|
|
99
96
|
# @return [Boolean]
|
100
97
|
#
|
101
98
|
# @example
|
102
|
-
# require "google/cloud"
|
99
|
+
# require "google/cloud/vision"
|
103
100
|
#
|
104
|
-
#
|
105
|
-
# vision = gcloud.vision
|
101
|
+
# vision = Google::Cloud::Vision.new
|
106
102
|
# image = vision.image "path/to/face.jpg"
|
107
103
|
#
|
108
104
|
# annotation = vision.annotate image, faces: 1
|
@@ -118,10 +114,9 @@ module Google
|
|
118
114
|
# @return [Array<Entity>]
|
119
115
|
#
|
120
116
|
# @example
|
121
|
-
# require "google/cloud"
|
117
|
+
# require "google/cloud/vision"
|
122
118
|
#
|
123
|
-
#
|
124
|
-
# vision = gcloud.vision
|
119
|
+
# vision = Google::Cloud::Vision.new
|
125
120
|
# image = vision.image "path/to/landmark.jpg"
|
126
121
|
#
|
127
122
|
# annotation = vision.annotate image, landmarks: 1
|
@@ -129,8 +124,8 @@ module Google
|
|
129
124
|
# landmark = annotation.landmarks.first
|
130
125
|
#
|
131
126
|
def landmarks
|
132
|
-
@landmarks ||= Array(@
|
133
|
-
Entity.
|
127
|
+
@landmarks ||= Array(@grpc.landmark_annotations).map do |lm|
|
128
|
+
Entity.from_grpc lm
|
134
129
|
end
|
135
130
|
end
|
136
131
|
|
@@ -140,10 +135,9 @@ module Google
|
|
140
135
|
# @return [Entity]
|
141
136
|
#
|
142
137
|
# @example
|
143
|
-
# require "google/cloud"
|
138
|
+
# require "google/cloud/vision"
|
144
139
|
#
|
145
|
-
#
|
146
|
-
# vision = gcloud.vision
|
140
|
+
# vision = Google::Cloud::Vision.new
|
147
141
|
# image = vision.image "path/to/landmark.jpg"
|
148
142
|
#
|
149
143
|
# annotation = vision.annotate image, landmarks: 1
|
@@ -160,10 +154,9 @@ module Google
|
|
160
154
|
# @return [Boolean]
|
161
155
|
#
|
162
156
|
# @example
|
163
|
-
# require "google/cloud"
|
157
|
+
# require "google/cloud/vision"
|
164
158
|
#
|
165
|
-
#
|
166
|
-
# vision = gcloud.vision
|
159
|
+
# vision = Google::Cloud::Vision.new
|
167
160
|
# image = vision.image "path/to/landmark.jpg"
|
168
161
|
#
|
169
162
|
# annotation = vision.annotate image, landmarks: 1
|
@@ -179,10 +172,9 @@ module Google
|
|
179
172
|
# @return [Array<Entity>]
|
180
173
|
#
|
181
174
|
# @example
|
182
|
-
# require "google/cloud"
|
175
|
+
# require "google/cloud/vision"
|
183
176
|
#
|
184
|
-
#
|
185
|
-
# vision = gcloud.vision
|
177
|
+
# vision = Google::Cloud::Vision.new
|
186
178
|
# image = vision.image "path/to/logo.jpg"
|
187
179
|
#
|
188
180
|
# annotation = vision.annotate image, logos: 1
|
@@ -190,8 +182,8 @@ module Google
|
|
190
182
|
# logo = annotation.logos.first
|
191
183
|
#
|
192
184
|
def logos
|
193
|
-
@logos ||= Array(@
|
194
|
-
Entity.
|
185
|
+
@logos ||= Array(@grpc.logo_annotations).map do |lg|
|
186
|
+
Entity.from_grpc lg
|
195
187
|
end
|
196
188
|
end
|
197
189
|
|
@@ -201,10 +193,9 @@ module Google
|
|
201
193
|
# @return [Entity]
|
202
194
|
#
|
203
195
|
# @example
|
204
|
-
# require "google/cloud"
|
196
|
+
# require "google/cloud/vision"
|
205
197
|
#
|
206
|
-
#
|
207
|
-
# vision = gcloud.vision
|
198
|
+
# vision = Google::Cloud::Vision.new
|
208
199
|
# image = vision.image "path/to/logo.jpg"
|
209
200
|
#
|
210
201
|
# annotation = vision.annotate image, logos: 1
|
@@ -221,10 +212,9 @@ module Google
|
|
221
212
|
# @return [Boolean]
|
222
213
|
#
|
223
214
|
# @example
|
224
|
-
# require "google/cloud"
|
215
|
+
# require "google/cloud/vision"
|
225
216
|
#
|
226
|
-
#
|
227
|
-
# vision = gcloud.vision
|
217
|
+
# vision = Google::Cloud::Vision.new
|
228
218
|
# image = vision.image "path/to/logo.jpg"
|
229
219
|
#
|
230
220
|
# annotation = vision.annotate image, logos: 1
|
@@ -240,10 +230,9 @@ module Google
|
|
240
230
|
# @return [Array<Entity>]
|
241
231
|
#
|
242
232
|
# @example
|
243
|
-
# require "google/cloud"
|
233
|
+
# require "google/cloud/vision"
|
244
234
|
#
|
245
|
-
#
|
246
|
-
# vision = gcloud.vision
|
235
|
+
# vision = Google::Cloud::Vision.new
|
247
236
|
# image = vision.image "path/to/face.jpg"
|
248
237
|
#
|
249
238
|
# annotation = vision.annotate image, labels: 1
|
@@ -251,8 +240,8 @@ module Google
|
|
251
240
|
# label = annotation.labels.first
|
252
241
|
#
|
253
242
|
def labels
|
254
|
-
@labels ||= Array(@
|
255
|
-
Entity.
|
243
|
+
@labels ||= Array(@grpc.label_annotations).map do |lb|
|
244
|
+
Entity.from_grpc lb
|
256
245
|
end
|
257
246
|
end
|
258
247
|
|
@@ -262,10 +251,9 @@ module Google
|
|
262
251
|
# @return [Entity]
|
263
252
|
#
|
264
253
|
# @example
|
265
|
-
# require "google/cloud"
|
254
|
+
# require "google/cloud/vision"
|
266
255
|
#
|
267
|
-
#
|
268
|
-
# vision = gcloud.vision
|
256
|
+
# vision = Google::Cloud::Vision.new
|
269
257
|
# image = vision.image "path/to/face.jpg"
|
270
258
|
#
|
271
259
|
# annotation = vision.annotate image, labels: 1
|
@@ -282,10 +270,9 @@ module Google
|
|
282
270
|
# @return [Boolean]
|
283
271
|
#
|
284
272
|
# @example
|
285
|
-
# require "google/cloud"
|
273
|
+
# require "google/cloud/vision"
|
286
274
|
#
|
287
|
-
#
|
288
|
-
# vision = gcloud.vision
|
275
|
+
# vision = Google::Cloud::Vision.new
|
289
276
|
# image = vision.image "path/to/face.jpg"
|
290
277
|
#
|
291
278
|
# annotation = vision.annotate image, labels: 1
|
@@ -301,17 +288,16 @@ module Google
|
|
301
288
|
# @return [Text]
|
302
289
|
#
|
303
290
|
# @example
|
304
|
-
# require "google/cloud"
|
291
|
+
# require "google/cloud/vision"
|
305
292
|
#
|
306
|
-
#
|
307
|
-
# vision = gcloud.vision
|
293
|
+
# vision = Google::Cloud::Vision.new
|
308
294
|
# image = vision.image "path/to/text.png"
|
309
295
|
#
|
310
296
|
# annotation = vision.annotate image, text: true
|
311
297
|
# text = annotation.text
|
312
298
|
#
|
313
299
|
def text
|
314
|
-
@text ||= Text.
|
300
|
+
@text ||= Text.from_grpc(@grpc.text_annotations)
|
315
301
|
end
|
316
302
|
|
317
303
|
##
|
@@ -320,10 +306,9 @@ module Google
|
|
320
306
|
# @return [Boolean]
|
321
307
|
#
|
322
308
|
# @example
|
323
|
-
# require "google/cloud"
|
309
|
+
# require "google/cloud/vision"
|
324
310
|
#
|
325
|
-
#
|
326
|
-
# vision = gcloud.vision
|
311
|
+
# vision = Google::Cloud::Vision.new
|
327
312
|
# image = vision.image "path/to/text.png"
|
328
313
|
#
|
329
314
|
# annotation = vision.annotate image, text: true
|
@@ -339,18 +324,17 @@ module Google
|
|
339
324
|
# @return [SafeSearch]
|
340
325
|
#
|
341
326
|
# @example
|
342
|
-
# require "google/cloud"
|
327
|
+
# require "google/cloud/vision"
|
343
328
|
#
|
344
|
-
#
|
345
|
-
# vision = gcloud.vision
|
329
|
+
# vision = Google::Cloud::Vision.new
|
346
330
|
# image = vision.image "path/to/face.jpg"
|
347
331
|
#
|
348
332
|
# annotation = vision.annotate image, safe_search: true
|
349
333
|
# safe_search = annotation.safe_search
|
350
334
|
#
|
351
335
|
def safe_search
|
352
|
-
return nil unless @
|
353
|
-
@safe_search ||= SafeSearch.
|
336
|
+
return nil unless @grpc.safe_search_annotation
|
337
|
+
@safe_search ||= SafeSearch.from_grpc(@grpc.safe_search_annotation)
|
354
338
|
end
|
355
339
|
|
356
340
|
##
|
@@ -360,10 +344,9 @@ module Google
|
|
360
344
|
# @return [Boolean]
|
361
345
|
#
|
362
346
|
# @example
|
363
|
-
# require "google/cloud"
|
347
|
+
# require "google/cloud/vision"
|
364
348
|
#
|
365
|
-
#
|
366
|
-
# vision = gcloud.vision
|
349
|
+
# vision = Google::Cloud::Vision.new
|
367
350
|
# image = vision.image "path/to/face.jpg"
|
368
351
|
#
|
369
352
|
# annotation = vision.annotate image, safe_search: true
|
@@ -379,19 +362,18 @@ module Google
|
|
379
362
|
# @return [Properties]
|
380
363
|
#
|
381
364
|
# @example
|
382
|
-
# require "google/cloud"
|
365
|
+
# require "google/cloud/vision"
|
383
366
|
#
|
384
|
-
#
|
385
|
-
# vision = gcloud.vision
|
367
|
+
# vision = Google::Cloud::Vision.new
|
386
368
|
# image = vision.image "path/to/face.jpg"
|
387
369
|
#
|
388
370
|
# annotation = vision.annotate image, properties: true
|
389
371
|
# properties = annotation.properties
|
390
372
|
#
|
391
373
|
def properties
|
392
|
-
return nil unless @
|
393
|
-
@properties ||= Properties.
|
394
|
-
@
|
374
|
+
return nil unless @grpc.image_properties_annotation
|
375
|
+
@properties ||= Properties.from_grpc(
|
376
|
+
@grpc.image_properties_annotation)
|
395
377
|
end
|
396
378
|
|
397
379
|
##
|
@@ -400,10 +382,9 @@ module Google
|
|
400
382
|
# @return [Boolean]
|
401
383
|
#
|
402
384
|
# @example
|
403
|
-
# require "google/cloud"
|
385
|
+
# require "google/cloud/vision"
|
404
386
|
#
|
405
|
-
#
|
406
|
-
# vision = gcloud.vision
|
387
|
+
# vision = Google::Cloud::Vision.new
|
407
388
|
# image = vision.image "path/to/face.jpg"
|
408
389
|
#
|
409
390
|
# annotation = vision.annotate image, properties: true
|
@@ -439,9 +420,9 @@ module Google
|
|
439
420
|
end
|
440
421
|
|
441
422
|
##
|
442
|
-
# @private New Annotation from a
|
443
|
-
def self.
|
444
|
-
new.tap { |a| a.instance_variable_set :@
|
423
|
+
# @private New Annotation from a GRPC object.
|
424
|
+
def self.from_grpc grpc
|
425
|
+
new.tap { |a| a.instance_variable_set :@grpc, grpc }
|
445
426
|
end
|
446
427
|
end
|
447
428
|
end
|
@@ -30,10 +30,9 @@ module Google
|
|
30
30
|
# @see https://developers.google.com/knowledge-graph/ Knowledge Graph
|
31
31
|
#
|
32
32
|
# @example
|
33
|
-
# require "google/cloud"
|
33
|
+
# require "google/cloud/vision"
|
34
34
|
#
|
35
|
-
#
|
36
|
-
# vision = gcloud.vision
|
35
|
+
# vision = Google::Cloud::Vision.new
|
37
36
|
#
|
38
37
|
# image = vision.image "path/to/landmark.jpg"
|
39
38
|
#
|
@@ -43,10 +42,9 @@ module Google
|
|
43
42
|
# landmark.mid #=> "/m/019dvv"
|
44
43
|
#
|
45
44
|
# @example
|
46
|
-
# require "google/cloud"
|
45
|
+
# require "google/cloud/vision"
|
47
46
|
#
|
48
|
-
#
|
49
|
-
# vision = gcloud.vision
|
47
|
+
# vision = Google::Cloud::Vision.new
|
50
48
|
#
|
51
49
|
# image = vision.image "path/to/logo.jpg"
|
52
50
|
#
|
@@ -56,10 +54,9 @@ module Google
|
|
56
54
|
# logo.mid #=> "/m/0b34hf"
|
57
55
|
#
|
58
56
|
# @example
|
59
|
-
# require "google/cloud"
|
57
|
+
# require "google/cloud/vision"
|
60
58
|
#
|
61
|
-
#
|
62
|
-
# vision = gcloud.vision
|
59
|
+
# vision = Google::Cloud::Vision.new
|
63
60
|
#
|
64
61
|
# image = vision.image "path/to/face.jpg"
|
65
62
|
#
|
@@ -73,13 +70,13 @@ module Google
|
|
73
70
|
#
|
74
71
|
class Entity
|
75
72
|
##
|
76
|
-
# @private The EntityAnnotation
|
77
|
-
attr_accessor :
|
73
|
+
# @private The EntityAnnotation GRPC object.
|
74
|
+
attr_accessor :grpc
|
78
75
|
|
79
76
|
##
|
80
77
|
# @private Creates a new Entity instance.
|
81
78
|
def initialize
|
82
|
-
@
|
79
|
+
@grpc = nil
|
83
80
|
end
|
84
81
|
|
85
82
|
##
|
@@ -91,7 +88,7 @@ module Google
|
|
91
88
|
# @return [String] The opaque entity ID.
|
92
89
|
#
|
93
90
|
def mid
|
94
|
-
@
|
91
|
+
@grpc.mid
|
95
92
|
end
|
96
93
|
|
97
94
|
##
|
@@ -103,7 +100,7 @@ module Google
|
|
103
100
|
# language code.
|
104
101
|
#
|
105
102
|
def locale
|
106
|
-
@
|
103
|
+
@grpc.locale
|
107
104
|
end
|
108
105
|
|
109
106
|
##
|
@@ -112,7 +109,7 @@ module Google
|
|
112
109
|
# @return [String] A description of the entity.
|
113
110
|
#
|
114
111
|
def description
|
115
|
-
@
|
112
|
+
@grpc.description
|
116
113
|
end
|
117
114
|
|
118
115
|
##
|
@@ -121,7 +118,7 @@ module Google
|
|
121
118
|
# @return [Float] A value in the range [0, 1].
|
122
119
|
#
|
123
120
|
def score
|
124
|
-
@
|
121
|
+
@grpc.score
|
125
122
|
end
|
126
123
|
|
127
124
|
##
|
@@ -132,7 +129,7 @@ module Google
|
|
132
129
|
# @return [Float] A value in the range [0, 1].
|
133
130
|
#
|
134
131
|
def confidence
|
135
|
-
@
|
132
|
+
@grpc.confidence
|
136
133
|
end
|
137
134
|
|
138
135
|
##
|
@@ -145,7 +142,7 @@ module Google
|
|
145
142
|
# @return [Float] A value in the range [0, 1].
|
146
143
|
#
|
147
144
|
def topicality
|
148
|
-
@
|
145
|
+
@grpc.topicality
|
149
146
|
end
|
150
147
|
|
151
148
|
##
|
@@ -155,9 +152,9 @@ module Google
|
|
155
152
|
# @return [Array<Vertex>] An array of vertices.
|
156
153
|
#
|
157
154
|
def bounds
|
158
|
-
return [] unless @
|
159
|
-
@bounds ||= Array(@
|
160
|
-
Vertex.
|
155
|
+
return [] unless @grpc.bounding_poly
|
156
|
+
@bounds ||= Array(@grpc.bounding_poly.vertices).map do |v|
|
157
|
+
Vertex.from_grpc v
|
161
158
|
end
|
162
159
|
end
|
163
160
|
|
@@ -172,8 +169,8 @@ module Google
|
|
172
169
|
# and longitude.
|
173
170
|
#
|
174
171
|
def locations
|
175
|
-
@locations ||= Array(@
|
176
|
-
Location.
|
172
|
+
@locations ||= Array(@grpc.locations).map do |l|
|
173
|
+
Location.from_grpc l.lat_lng
|
177
174
|
end
|
178
175
|
end
|
179
176
|
|
@@ -186,7 +183,7 @@ module Google
|
|
186
183
|
#
|
187
184
|
def properties
|
188
185
|
@properties ||=
|
189
|
-
Hash[Array(@
|
186
|
+
Hash[Array(@grpc.properties).map { |p| [p.name, p.value] }]
|
190
187
|
end
|
191
188
|
|
192
189
|
##
|
@@ -217,9 +214,9 @@ module Google
|
|
217
214
|
end
|
218
215
|
|
219
216
|
##
|
220
|
-
# @private New Annotation::Entity from a
|
221
|
-
def self.
|
222
|
-
new.tap { |f| f.instance_variable_set :@
|
217
|
+
# @private New Annotation::Entity from a GRPC object.
|
218
|
+
def self.from_grpc grpc
|
219
|
+
new.tap { |f| f.instance_variable_set :@grpc, grpc }
|
223
220
|
end
|
224
221
|
end
|
225
222
|
end
|