Class: Typingpool::Transcript

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/typingpool/transcript.rb,
lib/typingpool/transcript/chunk.rb

Overview

This is the model class for Typingpool’s final and most important output, a transcript of the Project audio in HTML format, with embedded audio. A Transcript instance is actually an enumerable container for Transcript::Chunk instances. Each Transcript::Chunk corresponds to an Amazon::HIT and to an audio “chunk” (file) that has been transcribed and which is part of a larger recording.

This class is likey to be done away with in the next few point versions of Typingpool. Functionality and data unique to Transcipt::Chunk can probably be rolled into Amazon::HIT. Transcript itself can probably be folded into Project, which would become a HIT container, and then we’d pass Project instances to the output template.

Defined Under Namespace

Classes: Chunk

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title = nil, chunks = []) ⇒ Transcript

Constructor. Takes an optional title (see above for explanation of title) and an optional array of Transcript::Chunk instances.



28
29
30
31
# File 'lib/typingpool/transcript.rb', line 28

def initialize(title=nil, chunks=[])
  @title = title
  @chunks = chunks
end

Instance Attribute Details

#subtitleObject

Get/set the subtitle of the transcript, corresponds to Project#local#subtitle (a.k.a data/subtitle.txt in the project dir)



24
25
26
# File 'lib/typingpool/transcript.rb', line 24

def subtitle
  @subtitle
end

#titleObject

Get/set the title of the transcript, typically corresponds to the name of the associated Project



20
21
22
# File 'lib/typingpool/transcript.rb', line 20

def title
  @title
end

Instance Method Details

#[](index) ⇒ Object

Takes an index, returns the Transcript::Chunk at that index.



41
42
43
# File 'lib/typingpool/transcript.rb', line 41

def [](index)
  @chunks[index]
end

#add_chunk(chunk) ⇒ Object

Takes a Transcript::Chunk instance and adds it to the Transcript instance.



51
52
53
# File 'lib/typingpool/transcript.rb', line 51

def add_chunk(chunk)
  @chunks.push(chunk)
end

#eachObject

Iterate of the Transcript::Chunk instances



34
35
36
37
38
# File 'lib/typingpool/transcript.rb', line 34

def each
  @chunks.each do |chunk|
    yield chunk
  end
end

#to_sObject

Returns chunks joined by double newlines



46
47
48
# File 'lib/typingpool/transcript.rb', line 46

def to_s
  @chunks.join("\n\n")
end