Class: AssemblyAI::Realtime::Word
- Inherits:
-
Object
- Object
- AssemblyAI::Realtime::Word
- Defined in:
- lib/assemblyai/realtime/types/word.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#confidence ⇒ Float
readonly
Confidence score of the word.
-
#end_ ⇒ Integer
readonly
End time of the word in milliseconds.
-
#start ⇒ Integer
readonly
Start time of the word in milliseconds.
-
#text ⇒ String
readonly
The word itself.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Realtime::Word
Deserialize a JSON object to an instance of Word.
-
.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(start:, end_:, confidence:, text:, additional_properties: nil) ⇒ AssemblyAI::Realtime::Word constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Word to a JSON object.
Constructor Details
#initialize(start:, end_:, confidence:, text:, additional_properties: nil) ⇒ AssemblyAI::Realtime::Word
31 32 33 34 35 36 37 38 |
# File 'lib/assemblyai/realtime/types/word.rb', line 31 def initialize(start:, end_:, confidence:, text:, additional_properties: nil) @start = start @end_ = end_ @confidence = confidence @text = text @additional_properties = additional_properties @_field_set = { "start": start, "end": end_, "confidence": confidence, "text": text } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/assemblyai/realtime/types/word.rb', line 18 def additional_properties @additional_properties end |
#confidence ⇒ Float (readonly)
Returns Confidence score of the word.
14 15 16 |
# File 'lib/assemblyai/realtime/types/word.rb', line 14 def confidence @confidence end |
#end_ ⇒ Integer (readonly)
Returns End time of the word in milliseconds.
12 13 14 |
# File 'lib/assemblyai/realtime/types/word.rb', line 12 def end_ @end_ end |
#start ⇒ Integer (readonly)
Returns Start time of the word in milliseconds.
10 11 12 |
# File 'lib/assemblyai/realtime/types/word.rb', line 10 def start @start end |
#text ⇒ String (readonly)
Returns The word itself.
16 17 18 |
# File 'lib/assemblyai/realtime/types/word.rb', line 16 def text @text end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Realtime::Word
Deserialize a JSON object to an instance of Word
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/assemblyai/realtime/types/word.rb', line 44 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) start = struct["start"] end_ = struct["end"] confidence = struct["confidence"] text = struct["text"] new( start: start, end_: end_, confidence: confidence, text: text, 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.
72 73 74 75 76 77 |
# File 'lib/assemblyai/realtime/types/word.rb', line 72 def self.validate_raw(obj:) 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.") obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence 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.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Word to a JSON object
62 63 64 |
# File 'lib/assemblyai/realtime/types/word.rb', line 62 def to_json(*_args) @_field_set&.to_json end |