Class: AssemblyAI::Transcripts::Timestamp

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start:, end_:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::Timestamp

Parameters:

  • start (Integer)

    The start time in milliseconds

  • end_ (Integer)

    The end time in milliseconds

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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.

Returns:

  • (Integer)

    The end time in milliseconds



13
14
15
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 13

def end_
  @end_
end

#startInteger (readonly)

Returns The start time in milliseconds.

Returns:

  • (Integer)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


51
52
53
# File 'lib/assemblyai/transcripts/types/timestamp.rb', line 51

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