Class: AssemblyAI::Transcripts::WordSearchMatch

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, count:, timestamps:, indexes:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::WordSearchMatch

Parameters:

  • text (String)

    The matched word

  • count (Integer)

    The total amount of times the word is in the transcript

  • timestamps (Array<AssemblyAI::Transcripts::WORD_SEARCH_TIMESTAMP>)

    An array of timestamps

  • indexes (Array<Integer>)

    An array of all index locations for that word within the ‘words` array of the completed transcript

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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 = timestamps
  @indexes = indexes
  @additional_properties = additional_properties
  @_field_set = { "text": text, "count": count, "timestamps": timestamps, "indexes": indexes }
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



20
21
22
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 20

def additional_properties
  @additional_properties
end

#countInteger (readonly)

Returns The total amount of times the word is in the transcript.

Returns:

  • (Integer)

    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

#indexesArray<Integer> (readonly)

Returns An array of all index locations for that word within the ‘words` array of the completed transcript.

Returns:

  • (Array<Integer>)

    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

#textString (readonly)

Returns The matched word.

Returns:

  • (String)

    The matched word



11
12
13
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 11

def text
  @text
end

#timestampsArray<AssemblyAI::Transcripts::WORD_SEARCH_TIMESTAMP> (readonly)

Returns An array of timestamps.

Returns:



15
16
17
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 15

def timestamps
  @timestamps
end

Class Method Details

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

Deserialize a JSON object to an instance of WordSearchMatch

Parameters:

  • json_object (String)

Returns:



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"]
  timestamps = struct["timestamps"]
  indexes = struct["indexes"]
  new(
    text: text,
    count: count,
    timestamps: 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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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.timestamps.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

Returns:

  • (String)


65
66
67
# File 'lib/assemblyai/transcripts/types/word_search_match.rb', line 65

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