Class: Copyleaks::SourceCodeSubmissionModel

Inherits:
AIDetectionSubmissionModel show all
Defined in:
lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb

Instance Attribute Summary collapse

Attributes inherited from AIDetectionSubmissionModel

#sandbox, #text

Instance Method Summary collapse

Constructor Details

#initialize(text, filename, sandbox = false) ⇒ SourceCodeSubmissionModel

Returns a new instance of SourceCodeSubmissionModel.

Parameters:

  • A (String)

    text string.

  • The (String)

    name of the file. Make sure to include the right extension for your file type.

  • Use (Boolean)

    sandbox mode to test your integration with the Copyleaks API for free.



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

def initialize(text, filename, sandbox = false)
  unless text.instance_of?(String)
    raise 'Copyleaks::SourceCodeSubmissionModel - text - text must be of type String'
  end
  unless filename.instance_of?(String)
    raise 'Copyleaks::SourceCodeSubmissionModel - filename - filename must be of type String'
  end
  super(text, sandbox)
  @filename = filename
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



27
28
29
# File 'lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb', line 27

def filename
  @filename
end

Instance Method Details

#as_json(*_args) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb', line 43

def as_json(*_args)
  {
    text: @text,
    sandbox: @sandbox,
    filename: @filename
  }.select { |_k, v| !v.nil? }
end

#to_json(*options) ⇒ Object



51
52
53
# File 'lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb', line 51

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