Class: Copyleaks::WritingAssistantSubmissionModel

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, sandbox = false, language = nil, score = nil) ⇒ WritingAssistantSubmissionModel

Returns a new instance of WritingAssistantSubmissionModel.

Parameters:

  • Text (String) —

    to produce Writing Assistant report for. 1 >= characters <= 25000

  • Use (Boolean) —

    sandbox mode to test your integration with the Copyleaks API without consuming any credits.

  • language (String) (defaults to: nil) —

    The language code of your content. Optional; if not provided, the system will attempt to auto-detect the language.

  • an (ScoreWeights) —

    object containing the score weights for different writing aspects (e.g., grammar, mechanics). Optional.



33
34
35
36
37
38
39
40
41
# File 'lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb', line 33

def initialize(text, sandbox = false, language = nil, score = nil)
  unless text.instance_of?(String)
    raise 'Copyleaks::WritingAssistantSubmissionModel - text - text must be of type String'
  end
  @text = text
  @sandbox = sandbox
  @language = language
  @score = score
end

Instance Attribute Details

#language ⇒ Object

Returns the value of attribute language.



27
28
29
# File 'lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb', line 27

def language
  @language
end

#sandbox ⇒ Object

Returns the value of attribute sandbox.



27
28
29
# File 'lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb', line 27

def sandbox
  @sandbox
end

#score ⇒ Object

Returns the value of attribute score.



27
28
29
# File 'lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb', line 27

def score
  @score
end

#text ⇒ Object

Returns the value of attribute text.



27
28
29
# File 'lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb', line 27

def text
  @text
end

Instance Method Details

#as_json(*_args) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb', line 43

def as_json(*_args)
  {
    text: @text,
    sandbox: @sandbox,
    language: @language,
    score: @score
  }.reject { |_k, v| v.nil? }
end

#to_json(*options) ⇒ Object



52
53
54
# File 'lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb', line 52

def to_json(*options)
  as_json(*options).to_json(*options)
end