Class: AssemblyAI::Transcripts::ContentSafetyLabel

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/transcripts/types/content_safety_label.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, confidence:, severity:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::ContentSafetyLabel

Parameters:

  • label (String)

    The label of the sensitive topic

  • confidence (Float)

    The confidence score for the topic being discussed, from 0 to 1

  • severity (Float)

    How severely the topic is discussed in the section, from 0 to 1

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



28
29
30
31
32
33
34
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 28

def initialize(label:, confidence:, severity:, additional_properties: nil)
  @label = label
  @confidence = confidence
  @severity = severity
  @additional_properties = additional_properties
  @_field_set = { "label": label, "confidence": confidence, "severity": severity }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



16
17
18
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 16

def additional_properties
  @additional_properties
end

#confidenceFloat (readonly)

Returns The confidence score for the topic being discussed, from 0 to 1.

Returns:

  • (Float)

    The confidence score for the topic being discussed, from 0 to 1



12
13
14
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 12

def confidence
  @confidence
end

#labelString (readonly)

Returns The label of the sensitive topic.

Returns:

  • (String)

    The label of the sensitive topic



10
11
12
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 10

def label
  @label
end

#severityFloat (readonly)

Returns How severely the topic is discussed in the section, from 0 to 1.

Returns:

  • (Float)

    How severely the topic is discussed in the section, from 0 to 1



14
15
16
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 14

def severity
  @severity
end

Class Method Details

.from_json(json_object:) ⇒ AssemblyAI::Transcripts::ContentSafetyLabel

Deserialize a JSON object to an instance of ContentSafetyLabel

Parameters:

  • json_object (String)

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 40

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  label = struct["label"]
  confidence = struct["confidence"]
  severity = struct["severity"]
  new(
    label: label,
    confidence: confidence,
    severity: severity,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


66
67
68
69
70
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 66

def self.validate_raw(obj:)
  obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
  obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
  obj.severity.is_a?(Float) != false || raise("Passed value for field obj.severity is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ContentSafetyLabel to a JSON object

Returns:

  • (String)


56
57
58
# File 'lib/assemblyai/transcripts/types/content_safety_label.rb', line 56

def to_json(*_args)
  @_field_set&.to_json
end