Class: AssemblyAI::Transcripts::Timestamp
- Inherits:
-
Object
- Object
- AssemblyAI::Transcripts::Timestamp
- Defined in:
- lib/assemblyai/transcripts/types/timestamp.rb
Overview
Timestamp containing a start and end property in milliseconds
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 end time in milliseconds.
-
#start ⇒ Integer
readonly
The start time in milliseconds.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::Timestamp
Deserialize a JSON object to an instance of Timestamp.
-
.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_:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::Timestamp constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Timestamp to a JSON object.
Constructor Details
#initialize(start:, end_:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::Timestamp
26 27 28 29 30 31 |
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 26 def initialize(start:, end_:, additional_properties: nil) @start = start @end_ = end_ @additional_properties = additional_properties @_field_set = { "start": start, "end": end_ } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
15 16 17 |
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 15 def additional_properties @additional_properties end |
#end_ ⇒ Integer (readonly)
Returns The end time in milliseconds.
13 14 15 |
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 13 def end_ @end_ end |
#start ⇒ Integer (readonly)
Returns The start time in milliseconds.
11 12 13 |
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 11 def start @start end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Transcripts::Timestamp
Deserialize a JSON object to an instance of Timestamp
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 37 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) start = struct["start"] end_ = struct["end"] new( 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.
61 62 63 64 |
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 61 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.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Timestamp to a JSON object
51 52 53 |
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 51 def to_json(*_args) @_field_set&.to_json end |