Class: Gcloud::Vision::Annotation::Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/vision/annotation/vertex.rb

Overview

# Vertex

A vertex in a set of bounding polygon vertices.

See Face::Bounds and Text.

Examples:

require "gcloud"

gcloud = Gcloud.new
vision = gcloud.vision

image = vision.image "path/to/text.png"
text = image.text

text.bounds.count #=> 4
vertex = text.bounds.first
vertex.x #=> 13
vertex.y #=> 8

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Vertex

Returns a new instance of Vertex.



48
49
50
51
# File 'lib/gcloud/vision/annotation/vertex.rb', line 48

def initialize x, y
  @x = x
  @y = y
end

Instance Attribute Details

#xInteger (readonly)

The X coordinate.

Returns:

  • (Integer)

    the current value of x



43
44
45
# File 'lib/gcloud/vision/annotation/vertex.rb', line 43

def x
  @x
end

#yInteger (readonly)

The Y coordinate.

Returns:

  • (Integer)

    the current value of y



43
44
45
# File 'lib/gcloud/vision/annotation/vertex.rb', line 43

def y
  @y
end

Class Method Details

.from_gapi(gapi) ⇒ Object

Client object.



102
103
104
# File 'lib/gcloud/vision/annotation/vertex.rb', line 102

def self.from_gapi gapi
  new gapi.x, gapi.y
end

Instance Method Details

#inspectObject



95
96
97
# File 'lib/gcloud/vision/annotation/vertex.rb', line 95

def inspect
  "#<Vertex #{self}>"
end

#to_aArray

Returns the object’s property values as an array.

Returns:

  • (Array)


58
59
60
# File 'lib/gcloud/vision/annotation/vertex.rb', line 58

def to_a
  to_ary
end

#to_aryArray

Returns the object’s property values as an array.

Returns:

  • (Array)


67
68
69
# File 'lib/gcloud/vision/annotation/vertex.rb', line 67

def to_ary
  [x, y]
end

#to_hHash

Converts object to a hash. All keys will be symbolized.

Returns:

  • (Hash)


76
77
78
# File 'lib/gcloud/vision/annotation/vertex.rb', line 76

def to_h
  to_hash
end

#to_hashHash

Converts object to a hash. All keys will be symbolized.

Returns:

  • (Hash)


85
86
87
# File 'lib/gcloud/vision/annotation/vertex.rb', line 85

def to_hash
  { x: x, y: y }
end

#to_sObject



90
91
92
# File 'lib/gcloud/vision/annotation/vertex.rb', line 90

def to_s
  "(x: #{x.inspect}, y: #{y.inspect})"
end