Class: Copyleaks::CopyleaksTextModerationRequestModel
- Inherits:
-
Object
- Object
- Copyleaks::CopyleaksTextModerationRequestModel
- Defined in:
- lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb
Instance Attribute Summary collapse
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#language ⇒ Object
Returns the value of attribute language.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text: '', sandbox: false, language: nil, labels: []) ⇒ CopyleaksTextModerationRequestModel
constructor
A new instance of CopyleaksTextModerationRequestModel.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(text: '', sandbox: false, language: nil, labels: []) ⇒ CopyleaksTextModerationRequestModel
Returns a new instance of CopyleaksTextModerationRequestModel.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb', line 34 def initialize(text: '', sandbox: false, language: nil, labels: []) @text = text @sandbox = sandbox @language = language @labels = labels raise ArgumentError, "String cannot be blank" if @text.nil? raise ArgumentError, "Labels must be a non-empty array." unless labels.is_a?(Array) && !labels.empty? raise ArgumentError, "Labels cannot have more than 32 elements." if labels.length > 32 end |
Instance Attribute Details
#labels ⇒ Object
Returns the value of attribute labels.
28 29 30 |
# File 'lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb', line 28 def labels @labels end |
#language ⇒ Object
Returns the value of attribute language.
28 29 30 |
# File 'lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb', line 28 def language @language end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
28 29 30 |
# File 'lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb', line 28 def sandbox @sandbox end |
#text ⇒ Object
Returns the value of attribute text.
28 29 30 |
# File 'lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb', line 28 def text @text end |
Class Method Details
.from_json(json_string) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb', line 56 def self.from_json(json_string) data = JSON.parse(json_string, symbolize_names: true) new( text: data[:text], sandbox: data[:sandbox], language: data[:language], labels: data[:labels] ) end |
Instance Method Details
#to_json(options = {}) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb', line 47 def to_json( = {}) { text: @text, sandbox: @sandbox, language: @language, labels: @labels }.to_json() end |