class Copyleaks::SourceCodeSubmissionModel

Attributes

filename[RW]

Public Class Methods

new(text, filename, sandbox = false) click to toggle source

@param [String] A text string. @param [String] The name of the file. Make sure to include the right extension for your file type. @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.

# 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

Public Instance Methods

as_json(*_args) click to toggle source
# 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) click to toggle source
# 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