Class: Copyleaks::TextModerationsLegend

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index: 0, id: '') ⇒ TextModerationsLegend

Returns a new instance of TextModerationsLegend.

Parameters:

  • index (integer) (defaults to: 0)

    The numerical index of the label.

  • id (string) (defaults to: '')

    A unique string identifier for the label. This ID serves as a machine-readable way to identify the label type.



9
10
11
12
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationsLegend.rb', line 9

def initialize(index: 0, id: '')
  @index = index
  @id = id
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

Class Method Details

.from_json(json_string) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/copyleaks/models/textModeration/responses/submodules/TextModerationsLegend.rb', line 21

def self.from_json(json_string)
  data = JSON.parse(json_string, symbolize_names: true)
  new(
    index: data[:index],
    id: data[:id]
  )
end

Instance Method Details

#to_json(options = {}) ⇒ Object



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

def to_json(options = {})
  {
    index: @index,
    id: @id
  }.to_json(options)
end