Class: AssemblyAI::Transcripts::Entity
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::Entity
- Defined in:
- lib/assemblyai/transcripts/types/entity.rb
Overview
A detected entity
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#end_ ⇒ Integer
readonly
The ending time, in milliseconds, for the detected entity in the audio file.
-
#entity_type ⇒ AssemblyAI::Transcripts::EntityType
readonly
The type of entity for the detected entity.
-
#start ⇒ Integer
readonly
The starting time, in milliseconds, at which the detected entity appears in the audio file.
-
#text ⇒ String
readonly
The text for the detected entity.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::Entity
Deserialize a JSON object to an instance of Entity.
-
.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.
Instance Method Summary collapse
- #initialize(entity_type:, text:, start:, end_:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::Entity constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Entity to a JSON object.
Constructor Details
#initialize(entity_type:, text:, start:, end_:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::Entity
35 36 37 38 39 40 41 42 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 35 def initialize(entity_type:, text:, start:, end_:, additional_properties: nil) @entity_type = entity_type @text = text @start = start @end_ = end_ @additional_properties = additional_properties @_field_set = { "entity_type": entity_type, "text": text, "start": start, "end": end_ } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
21 22 23 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 21 def additional_properties @additional_properties end |
#end_ ⇒ Integer (readonly)
Returns The ending time, in milliseconds, for the detected entity in the audio file.
19 20 21 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 19 def end_ @end_ end |
#entity_type ⇒ AssemblyAI::Transcripts::EntityType (readonly)
Returns The type of entity for the detected entity.
12 13 14 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 12 def entity_type @entity_type end |
#start ⇒ Integer (readonly)
Returns The starting time, in milliseconds, at which the detected entity appears in the audio file.
17 18 19 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 17 def start @start end |
#text ⇒ String (readonly)
Returns The text for the detected entity.
14 15 16 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 14 def text @text end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::Entity
Deserialize a JSON object to an instance of Entity
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 48 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) entity_type = struct["entity_type"] text = struct["text"] start = struct["start"] end_ = struct["end"] new( entity_type: entity_type, text: text, start: start, end_: end_, 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.
76 77 78 79 80 81 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 76 def self.validate_raw(obj:) obj.entity_type.is_a?(AssemblyAI::Transcripts::EntityType) != false || raise("Passed value for field obj.entity_type is not the expected type, validation failed.") obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.start.is_a?(Integer) != false || raise("Passed value for field obj.start is not the expected type, validation failed.") obj.end_.is_a?(Integer) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Entity to a JSON object
66 67 68 |
# File 'lib/assemblyai/transcripts/types/entity.rb', line 66 def to_json(*_args) @_field_set&.to_json end |