Class: Gcloud::Vision::Image::Context::Area
- Inherits:
-
Object
- Object
- Gcloud::Vision::Image::Context::Area
- Defined in:
- lib/gcloud/vision/image.rb
Overview
# Image::Context::Area
A Lat/long rectangle that specifies the location of the image.
Instance Attribute Summary collapse
-
#max ⇒ Location
Returns the max lat/long pair.
-
#min ⇒ Location
Returns the min lat/long pair.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Returns ‘true` if either `min` or `max` are not populated.
-
#initialize ⇒ Area
constructor
A new instance of Area.
- #to_gapi ⇒ Object
-
#to_h ⇒ Hash
Deeply converts object to a hash.
-
#to_hash ⇒ Hash
Deeply converts object to a hash.
Constructor Details
#initialize ⇒ Area
Returns a new instance of Area.
514 515 516 517 |
# File 'lib/gcloud/vision/image.rb', line 514 def initialize @min = Location.new nil, nil @max = Location.new nil, nil end |
Instance Attribute Details
#max ⇒ Location
Returns the max lat/long pair.
510 511 512 |
# File 'lib/gcloud/vision/image.rb', line 510 def max @max end |
#min ⇒ Location
Returns the min lat/long pair.
506 507 508 |
# File 'lib/gcloud/vision/image.rb', line 506 def min @min end |
Instance Method Details
#empty? ⇒ Boolean
Returns ‘true` if either `min` or `max` are not populated.
556 557 558 559 |
# File 'lib/gcloud/vision/image.rb', line 556 def empty? min.to_hash.values.reject(&:nil?).empty? || max.to_hash.values.reject(&:nil?).empty? end |
#to_gapi ⇒ Object
579 580 581 582 583 584 585 |
# File 'lib/gcloud/vision/image.rb', line 579 def to_gapi return nil if empty? Google::Apis::VisionV1::LatLongRect.new( min_lat_lng: min.to_gapi, max_lat_lng: max.to_gapi ) end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
566 567 568 |
# File 'lib/gcloud/vision/image.rb', line 566 def to_h to_hash end |
#to_hash ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
575 576 577 |
# File 'lib/gcloud/vision/image.rb', line 575 def to_hash { min_lat_lng: min.to_hash, max_lat_lng: max.to_hash } end |