Class: Copyleaks::CopyleaksTextModerationResponseModel
- Inherits:
-
Object
- Object
- Copyleaks::CopyleaksTextModerationResponseModel
- Defined in:
- lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb
Instance Attribute Summary collapse
-
#legend ⇒ Object
Returns the value of attribute legend.
-
#moderations ⇒ Object
Returns the value of attribute moderations.
-
#scanned_document ⇒ Object
Returns the value of attribute scanned_document.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(moderations: ModerationsModel.new, legend: [], scanned_document: TextModerationScannedDocument.new, **_ignored) ⇒ CopyleaksTextModerationResponseModel
constructor
A new instance of CopyleaksTextModerationResponseModel.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(moderations: ModerationsModel.new, legend: [], scanned_document: TextModerationScannedDocument.new, **_ignored) ⇒ CopyleaksTextModerationResponseModel
Returns a new instance of CopyleaksTextModerationResponseModel.
10 11 12 13 14 |
# File 'lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb', line 10 def initialize(moderations: ModerationsModel.new, legend: [], scanned_document: TextModerationScannedDocument.new, **_ignored) @moderations = moderations @legend = legend @scanned_document = scanned_document end |
Instance Attribute Details
#legend ⇒ Object
Returns the value of attribute legend.
5 6 7 |
# File 'lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb', line 5 def legend @legend end |
#moderations ⇒ Object
Returns the value of attribute moderations.
5 6 7 |
# File 'lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb', line 5 def moderations @moderations end |
#scanned_document ⇒ Object
Returns the value of attribute scanned_document.
5 6 7 |
# File 'lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb', line 5 def scanned_document @scanned_document end |
Class Method Details
.from_json(json_string) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb', line 26 def self.from_json(json_string) data = JSON.parse(json_string, symbolize_names: true) new( moderations: data[:moderations] ? ModerationsModel.from_json(data[:moderations].to_json) : nil, legend: data[:legend].map { |l| TextModerationsLegend.from_json(l.to_json) }, scanned_document: data[:scannedDocument] ? TextModerationScannedDocument.from_json(data[:scannedDocument].to_json) : nil ) end |
Instance Method Details
#to_json(options = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb', line 17 def to_json( = {}) { moderations: @moderations ? JSON.parse(@moderations.to_json) : nil, legend: @legend.map(&:to_json).map { |l| JSON.parse(l) }, scannedDocument: @scanned_document ? JSON.parse(@scanned_document.to_json) : nil }.to_json() end |