Class: Gcloud::Vision::Annotation::SafeSearch
- Inherits:
-
Object
- Object
- Gcloud::Vision::Annotation::SafeSearch
- Defined in:
- lib/gcloud/vision/annotation/safe_search.rb
Overview
# SafeSearch
A set of features pertaining to the image, computed by various computer vision methods over safe-search verticals (for example, adult, spoof, medical, violence).
Constant Summary collapse
- POSITIVE_RATINGS =
%w(POSSIBLE LIKELY VERY_LIKELY)
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#adult ⇒ Object
Adult likelihood rating.
-
#adult? ⇒ Boolean
Adult likelihood.
-
#initialize ⇒ SafeSearch
constructor
A new instance of SafeSearch.
- #inspect ⇒ Object
-
#medical ⇒ Object
Medical likelihood rating.
-
#medical? ⇒ Boolean
Medical likelihood.
-
#spoof ⇒ Object
Spoof likelihood rating.
-
#spoof? ⇒ Boolean
Spoof likelihood.
-
#to_h ⇒ Hash
Converts object to a hash.
-
#to_hash ⇒ Hash
Converts object to a hash.
- #to_s ⇒ Object
-
#violence ⇒ Object
Violence likelihood rating.
-
#violence? ⇒ Boolean
Violence likelihood.
Constructor Details
#initialize ⇒ SafeSearch
Returns a new instance of SafeSearch.
49 50 51 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 49 def initialize @gapi = {} end |
Instance Attribute Details
#gapi ⇒ Object
45 46 47 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 45 def gapi @gapi end |
Class Method Details
.from_gapi(gapi) ⇒ Object
155 156 157 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 155 def self.from_gapi gapi new.tap { |f| f.instance_variable_set :@gapi, gapi } end |
Instance Method Details
#adult ⇒ Object
Adult likelihood rating. Possible values are ‘VERY_UNLIKELY`, `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
56 57 58 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 56 def adult @gapi["adult"] end |
#adult? ⇒ Boolean
Adult likelihood. Returns ‘true` if #adult is `POSSIBLE`, `LIKELY`, or `VERY_LIKELY`.
66 67 68 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 66 def adult? POSITIVE_RATINGS.include? adult end |
#inspect ⇒ Object
149 150 151 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 149 def inspect "#<SafeSearch #{self}>" end |
#medical ⇒ Object
Medical likelihood rating. Possible values are ‘VERY_UNLIKELY`, `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
90 91 92 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 90 def medical @gapi["medical"] end |
#medical? ⇒ Boolean
Medical likelihood. Returns ‘true` if #medical is `POSSIBLE`, `LIKELY`, or `VERY_LIKELY`.
100 101 102 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 100 def medical? POSITIVE_RATINGS.include? medical end |
#spoof ⇒ Object
Spoof likelihood rating. Possible values are ‘VERY_UNLIKELY`, `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
73 74 75 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 73 def spoof @gapi["spoof"] end |
#spoof? ⇒ Boolean
Spoof likelihood. Returns ‘true` if #spoof is `POSSIBLE`, `LIKELY`, or `VERY_LIKELY`.
83 84 85 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 83 def spoof? POSITIVE_RATINGS.include? spoof end |
#to_h ⇒ Hash
Converts object to a hash. All keys will be symbolized.
126 127 128 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 126 def to_h to_hash end |
#to_hash ⇒ Hash
Converts object to a hash. All keys will be symbolized.
135 136 137 138 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 135 def to_hash { adult: adult?, spoof: spoof?, medical: medical?, violence: violence? } end |
#to_s ⇒ Object
141 142 143 144 145 146 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 141 def to_s tmplt = "(adult?: %s, spoof?: %s, medical?: %s, " \ "violence?: %s)" format tmplt, adult?.inspect, spoof?.inspect, medical?.inspect, violence?.inspect end |
#violence ⇒ Object
Violence likelihood rating. Possible values are ‘VERY_UNLIKELY`, `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
107 108 109 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 107 def violence @gapi["violence"] end |
#violence? ⇒ Boolean
Violence likelihood. Returns ‘true` if #violence is `POSSIBLE`, `LIKELY`, or `VERY_LIKELY`.
117 118 119 |
# File 'lib/gcloud/vision/annotation/safe_search.rb', line 117 def violence? POSITIVE_RATINGS.include? violence end |