Class: Copyleaks::SubmissionCrossLanguages

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/submissions/properties/cross_languages.rb

Instance Method Summary collapse

Constructor Details

#initialize(languages = nil) ⇒ SubmissionCrossLanguages

Returns a new instance of SubmissionCrossLanguages.

Parameters:

  • languages (Language[]) (defaults to: nil)
    • Languages to scan your content against.



27
28
29
30
31
32
# File 'lib/copyleaks/models/submissions/properties/cross_languages.rb', line 27

def initialize(languages = nil)
  if !languages.nil? && !(languages.is_a?(Array) && languages.all? { |element| element.is_a?(SubmissionLanguage) })
      raise 'Copyleaks::SubmissionCrossLanguages - languages - languages must be of type SubmissionLanguage[]'
  end
  @languages = languages
end

Instance Method Details

#as_json(*_args) ⇒ Object



34
35
36
37
38
# File 'lib/copyleaks/models/submissions/properties/cross_languages.rb', line 34

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

#to_json(*options) ⇒ Object



40
41
42
# File 'lib/copyleaks/models/submissions/properties/cross_languages.rb', line 40

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