Class: Copyleaks::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database: nil, batch: nil, repositories: nil, score: nil, internet: nil) ⇒ Results

Returns a new instance of Results.

Parameters:

  • database (Array<Database>) (defaults to: nil)
  • batch (Array<Batch>) (defaults to: nil)
  • repositories (Array<Repositories>) (defaults to: nil)
  • score (Score) (defaults to: nil)
  • internet (Array<Internet>) (defaults to: nil)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 30

def initialize(database: nil, batch: nil, repositories: nil, score: nil, internet: nil)
  if !database.nil? && !(database.is_a?(Array) && database.all? { |d| d.is_a?(Database) })
    raise 'Copyleaks::Results - database must be an array of Database objects'
  end
  if !batch.nil? && !(batch.is_a?(Array) && batch.all? { |b| b.is_a?(Batch) })
    raise 'Copyleaks::Results - batch must be an array of Batch objects'
  end
  if !repositories.nil? && !(repositories.is_a?(Array) && repositories.all? { |r| r.is_a?(Repositories) })
    raise 'Copyleaks::Results - repositories must be an array of Repositories objects'
  end
  if !score.nil? && !score.is_a?(Score)
    raise 'Copyleaks::Results - score must be a Score object'
  end
  if !internet.nil? && !(internet.is_a?(Array) && internet.all? { |i| i.is_a?(Internet) })
    raise 'Copyleaks::Results - internet must be an array of Internet objects'
  end

  @database = database
  @batch = batch
  @repositories = repositories
  @score = score
  @internet = internet
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.



23
24
25
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 23

def batch
  @batch
end

#databaseObject (readonly)

Returns the value of attribute database.



23
24
25
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 23

def database
  @database
end

#internetObject (readonly)

Returns the value of attribute internet.



23
24
25
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 23

def internet
  @internet
end

#repositoriesObject (readonly)

Returns the value of attribute repositories.



23
24
25
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 23

def repositories
  @repositories
end

#scoreObject (readonly)

Returns the value of attribute score.



23
24
25
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 23

def score
  @score
end

Instance Method Details

#as_json(*_args) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 54

def as_json(*_args)
  {
    database: @database,
    batch: @batch,
    repositories: @repositories,
    score: @score,
    internet: @internet
  }.select { |_k, v| !v.nil? }
end

#to_json(*options) ⇒ Object



64
65
66
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb', line 64

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