Class: Google::Cloud::Vision::Annotation::Properties
- Inherits:
-
Object
- Object
- Google::Cloud::Vision::Annotation::Properties
- Defined in:
- lib/google/cloud/vision/annotation/properties.rb
Overview
# Properties
A set of properties about an image, such as the image’s dominant colors.
See Image#properties.
Defined Under Namespace
Classes: Color
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#colors ⇒ Array<Color>
The image’s dominant colors, including their corresponding scores.
-
#initialize ⇒ Properties
constructor
A new instance of Properties.
- #inspect ⇒ Object
-
#to_a ⇒ Array
Returns the object’s property values as an array.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Properties
Returns a new instance of Properties.
45 46 47 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 45 def initialize @grpc = nil end |
Instance Attribute Details
#grpc ⇒ Object
41 42 43 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 41 def grpc @grpc end |
Class Method Details
.from_grpc(grpc) ⇒ Object
91 92 93 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 91 def self.from_grpc grpc new.tap { |f| f.instance_variable_set :@grpc, grpc } end |
Instance Method Details
#colors ⇒ Array<Color>
The image’s dominant colors, including their corresponding scores.
54 55 56 57 58 59 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 54 def colors return [] unless @grpc.dominant_colors @colors ||= Array(@grpc.dominant_colors.colors).map do |c| Color.from_grpc c end end |
#inspect ⇒ Object
85 86 87 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 85 def inspect "#<Properties #{self}>" end |
#to_a ⇒ Array
Returns the object’s property values as an array.
66 67 68 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 66 def to_a colors.map(&:rgb) end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
75 76 77 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 75 def to_h { colors: colors.map(&:to_h) } end |
#to_s ⇒ Object
80 81 82 |
# File 'lib/google/cloud/vision/annotation/properties.rb', line 80 def to_s "(colors: #{colors.count})" end |