Class: Copyleaks::ModerationsModel

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text: Text.new) ⇒ ModerationsModel

Returns a new instance of ModerationsModel.

Parameters:

  • text (Text) (defaults to: Text.new)

    Moderated text segments corresponding to the submitted text. Each position in the inner arrays corresponds to a single segment in the textual version.



8
9
10
# File 'lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb', line 8

def initialize(text: Text.new)
  @text = text
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



5
6
7
# File 'lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb', line 5

def text
  @text
end

Class Method Details

.from_json(json_string) ⇒ Object



19
20
21
22
23
24
# File 'lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb', line 19

def self.from_json(json_string)
  data = JSON.parse(json_string, symbolize_names: true)
  new(
    text: data[:text] ? Text.from_json(data[:text].to_json) : nil
  )
end

Instance Method Details

#to_json(options = {}) ⇒ Object



12
13
14
15
16
# File 'lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb', line 12

def to_json(options = {})
  {
    text: @text ? JSON.parse(@text.to_json) : nil
  }.to_json(options)
end