Class: AssemblyAI::Transcripts::WordSearchMatch
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::WordSearchMatch
- Defined in:
- lib/assemblyai/transcripts/types/word_search_match.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#count ⇒ Integer
readonly
The total amount of times the word is in the transcript.
-
#indexes ⇒ Array<Integer>
readonly
An array of all index locations for that word within the ‘words` array of the completed transcript.
-
#text ⇒ String
readonly
The matched word.
-
#timestamps ⇒ Array<AssemblyAI::Transcripts::WORD_SEARCH_TIMESTAMP>
readonly
An array of timestamps.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::WordSearchMatch
Deserialize a JSON object to an instance of WordSearchMatch.
-
.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(text:, count:, timestamps:, indexes:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::WordSearchMatch constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WordSearchMatch to a JSON object.
Constructor Details
#initialize(text:, count:, timestamps:, indexes:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::WordSearchMatch
34 35 36 37 38 39 40 41 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 34 def initialize(text:, count:, timestamps:, indexes:, additional_properties: nil) @text = text @count = count @timestamps = @indexes = indexes @additional_properties = additional_properties @_field_set = { "text": text, "count": count, "timestamps": , "indexes": indexes } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 20 def additional_properties @additional_properties end |
#count ⇒ Integer (readonly)
Returns The total amount of times the word is in the transcript.
13 14 15 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 13 def count @count end |
#indexes ⇒ Array<Integer> (readonly)
Returns An array of all index locations for that word within the ‘words` array of the completed transcript.
18 19 20 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 18 def indexes @indexes end |
#text ⇒ String (readonly)
Returns The matched word.
11 12 13 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 11 def text @text end |
#timestamps ⇒ Array<AssemblyAI::Transcripts::WORD_SEARCH_TIMESTAMP> (readonly)
Returns An array of timestamps.
15 16 17 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 15 def @timestamps end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::WordSearchMatch
Deserialize a JSON object to an instance of WordSearchMatch
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 47 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) text = struct["text"] count = struct["count"] = struct["timestamps"] indexes = struct["indexes"] new( text: text, count: count, timestamps: , indexes: indexes, 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.
75 76 77 78 79 80 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 75 def self.validate_raw(obj:) obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.count.is_a?(Integer) != false || raise("Passed value for field obj.count is not the expected type, validation failed.") obj..is_a?(Array) != false || raise("Passed value for field obj.timestamps is not the expected type, validation failed.") obj.indexes.is_a?(Array) != false || raise("Passed value for field obj.indexes is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WordSearchMatch to a JSON object
65 66 67 |
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 65 def to_json(*_args) @_field_set&.to_json end |