Class: AssemblyAI::Transcripts::Chapter

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

Overview

Chapter of the audio file

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gist:, headline:, summary:, start:, end_:, additional_properties: nil) ⇒ AssemblyAI::Transcripts::Chapter

Parameters:

  • gist (String)

    An ultra-short summary (just a few words) of the content spoken in the chapter

  • headline (String)

    A single sentence summary of the content spoken during the chapter

  • summary (String)

    A one paragraph summary of the content spoken during the chapter

  • start (Integer)

    The starting time, in milliseconds, for the chapter

  • end_ (Integer)

    The starting time, in milliseconds, for the chapter

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



35
36
37
38
39
40
41
42
43
# File 'lib/assemblyai/transcripts/types/chapter.rb', line 35

def initialize(gist:, headline:, summary:, start:, end_:, additional_properties: nil)
  @gist = gist
  @headline = headline
  @summary = summary
  @start = start
  @end_ = end_
  @additional_properties = additional_properties
  @_field_set = { "gist": gist, "headline": headline, "summary": summary, "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



21
22
23
# File 'lib/assemblyai/transcripts/types/chapter.rb', line 21

def additional_properties
  @additional_properties
end

#end_Integer (readonly)

Returns The starting time, in milliseconds, for the chapter.

Returns:

  • (Integer)

    The starting time, in milliseconds, for the chapter



19
20
21
# File 'lib/assemblyai/transcripts/types/chapter.rb', line 19

def end_
  @end_
end

#gistString (readonly)

Returns An ultra-short summary (just a few words) of the content spoken in the chapter.

Returns:

  • (String)

    An ultra-short summary (just a few words) of the content spoken in the chapter



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

def gist
  @gist
end

#headlineString (readonly)

Returns A single sentence summary of the content spoken during the chapter.

Returns:

  • (String)

    A single sentence summary of the content spoken during the chapter



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

def headline
  @headline
end

#startInteger (readonly)

Returns The starting time, in milliseconds, for the chapter.

Returns:

  • (Integer)

    The starting time, in milliseconds, for the chapter



17
18
19
# File 'lib/assemblyai/transcripts/types/chapter.rb', line 17

def start
  @start
end

#summaryString (readonly)

Returns A one paragraph summary of the content spoken during the chapter.

Returns:

  • (String)

    A one paragraph summary of the content spoken during the chapter



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

def summary
  @summary
end

Class Method Details

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

Deserialize a JSON object to an instance of Chapter

Parameters:

  • json_object (String)

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/assemblyai/transcripts/types/chapter.rb', line 49

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  gist = struct["gist"]
  headline = struct["headline"]
  summary = struct["summary"]
  start = struct["start"]
  end_ = struct["end"]
  new(
    gist: gist,
    headline: headline,
    summary: summary,
    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)


79
80
81
82
83
84
85
# File 'lib/assemblyai/transcripts/types/chapter.rb', line 79

def self.validate_raw(obj:)
  obj.gist.is_a?(String) != false || raise("Passed value for field obj.gist is not the expected type, validation failed.")
  obj.headline.is_a?(String) != false || raise("Passed value for field obj.headline is not the expected type, validation failed.")
  obj.summary.is_a?(String) != false || raise("Passed value for field obj.summary is not the expected type, validation failed.")
  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 Chapter to a JSON object

Returns:

  • (String)


69
70
71
# File 'lib/assemblyai/transcripts/types/chapter.rb', line 69

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