Class: Gcloud::Vision::Annotation::Properties
- Inherits:
-
Object
- Object
- Gcloud::Vision::Annotation::Properties
- Defined in:
- lib/gcloud/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_ary ⇒ Array
Returns the object’s property values as an array.
-
#to_h ⇒ Hash
Deeply converts object to a hash.
-
#to_hash ⇒ Hash
Deeply converts object to a hash.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Properties
44 45 46 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 44 def initialize @gapi = {} end |
Instance Attribute Details
#gapi ⇒ Object
40 41 42 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 40 def gapi @gapi end |
Class Method Details
.from_gapi(gapi) ⇒ Object
108 109 110 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 108 def self.from_gapi gapi new.tap { |f| f.instance_variable_set :@gapi, gapi } end |
Instance Method Details
#colors ⇒ Array<Color>
The image’s dominant colors, including their corresponding scores.
53 54 55 56 57 58 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 53 def colors return [] unless @gapi.dominant_colors @colors ||= Array(@gapi.dominant_colors.colors).map do |c| Color.from_gapi c end end |
#inspect ⇒ Object
102 103 104 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 102 def inspect "#<Properties #{self}>" end |
#to_a ⇒ Array
Returns the object’s property values as an array.
65 66 67 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 65 def to_a to_ary end |
#to_ary ⇒ Array
Returns the object’s property values as an array.
74 75 76 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 74 def to_ary colors.map(&:rgb) end |
#to_h ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
83 84 85 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 83 def to_h to_hash end |
#to_hash ⇒ Hash
Deeply converts object to a hash. All keys will be symbolized.
92 93 94 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 92 def to_hash { colors: colors.map(&:to_h) } end |
#to_s ⇒ Object
97 98 99 |
# File 'lib/gcloud/vision/annotation/properties.rb', line 97 def to_s "(colors: #{colors.count})" end |