Class: Copyleaks::TextModerationScannedDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scan_id: '', total_words: 0, total_excluded: 0, actual_credits: 0, expected_credits: 0, creation_time: Time.utc.now) ⇒ TextModerationScannedDocument

Returns a new instance of TextModerationScannedDocument.

Parameters:

  • scan_id (String) (defaults to: '')

    The scan id given by the user.

  • total_words (Integer) (defaults to: 0)

    Total number of words found in the scanned text.

  • total_excluded (Integer) (defaults to: 0)

    Total excluded words from the text.

  • actual_credits (Integer) (defaults to: 0)

    The cost of credits for this scan.

  • expected_credits (Integer) (defaults to: 0)

    The amount of credits that was expected to be spent on the scan.

  • creation_time (Time) (defaults to: Time.utc.now)

    Creation time of the scan.



14
15
16
17
18
19
20
21
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 14

def initialize(scan_id: '', total_words: 0, total_excluded: 0, actual_credits: 0, expected_credits: 0, creation_time: Time.utc.now)
  @scan_id = scan_id
  @total_words = total_words
  @total_excluded = total_excluded
  @actual_credits = actual_credits
  @expected_credits = expected_credits
  @creation_time = creation_time
end

Instance Attribute Details

#actual_creditsObject

Returns the value of attribute actual_credits.



6
7
8
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 6

def actual_credits
  @actual_credits
end

#creation_timeObject

Returns the value of attribute creation_time.



6
7
8
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 6

def creation_time
  @creation_time
end

#expected_creditsObject

Returns the value of attribute expected_credits.



6
7
8
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 6

def expected_credits
  @expected_credits
end

#scan_idObject

Returns the value of attribute scan_id.



6
7
8
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 6

def scan_id
  @scan_id
end

#total_excludedObject

Returns the value of attribute total_excluded.



6
7
8
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 6

def total_excluded
  @total_excluded
end

#total_wordsObject

Returns the value of attribute total_words.



6
7
8
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 6

def total_words
  @total_words
end

Class Method Details

.from_json(json_string) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 35

def self.from_json(json_string)
  data = JSON.parse(json_string, symbolize_names: true)
  new(
    scan_id: data[:scanId],
    total_words: data[:totalWords],
    total_excluded: data[:totalExcluded],
    actual_credits: data[:actualCredits],
    expected_credits: data[:expectedCredits],
    creation_time: Time.parse(data[:creationTime]) 
  )
end

Instance Method Details

#to_json(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb', line 24

def to_json(options = {})
  {
    scanId: @scan_id,
    totalWords: @total_words,
    totalExcluded: @total_excluded,
    actualCredits: @actual_credits,
    expectedCredits: @expected_credits,
    creationTime: @creation_time.iso8601
  }.to_json(options)
end