Class: DuoSplitter::Models::Sentence

Inherits:
Object
  • Object
show all
Defined in:
lib/duo_splitter/models/sentence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number:, start_pos:, end_pos:, section:) ⇒ Sentence

Returns a new instance of Sentence.



10
11
12
13
14
15
# File 'lib/duo_splitter/models/sentence.rb', line 10

def initialize(number:, start_pos:, end_pos:, section:)
  @number = number
  @start_pos = start_pos
  @end_pos = end_pos
  @section = section
end

Instance Attribute Details

#audio_pathObject

Returns the value of attribute audio_path.



8
9
10
# File 'lib/duo_splitter/models/sentence.rb', line 8

def audio_path
  @audio_path
end

#blank_audio_pathObject

Returns the value of attribute blank_audio_path.



8
9
10
# File 'lib/duo_splitter/models/sentence.rb', line 8

def blank_audio_path
  @blank_audio_path
end

#end_posObject (readonly)

Returns the value of attribute end_pos.



6
7
8
# File 'lib/duo_splitter/models/sentence.rb', line 6

def end_pos
  @end_pos
end

#numberObject (readonly)

Returns the value of attribute number.



6
7
8
# File 'lib/duo_splitter/models/sentence.rb', line 6

def number
  @number
end

#sectionObject (readonly)

Returns the value of attribute section.



6
7
8
# File 'lib/duo_splitter/models/sentence.rb', line 6

def section
  @section
end

#source_audio_pathObject

Returns the value of attribute source_audio_path.



8
9
10
# File 'lib/duo_splitter/models/sentence.rb', line 8

def source_audio_path
  @source_audio_path
end

#start_posObject (readonly)

Returns the value of attribute start_pos.



6
7
8
# File 'lib/duo_splitter/models/sentence.rb', line 6

def start_pos
  @start_pos
end

Instance Method Details

#durationObject



17
18
19
# File 'lib/duo_splitter/models/sentence.rb', line 17

def duration
  Float(@end_pos) - Float(@start_pos)
end

#intro?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/duo_splitter/models/sentence.rb', line 21

def intro?
  number.zero?
end

#output_basename(ext:, prefix_section_number: true, blank: false, concatenated: false) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/duo_splitter/models/sentence.rb', line 25

def output_basename(ext:, prefix_section_number: true, blank: false, concatenated: false)
  basename = format('%03<number>d', number: number)
  basename = "#{basename}_blank" if blank
  basename = "#{basename}_concatenated" if concatenated
  basename = "#{basename}.#{ext}"
  basename = format('%02<section_number>d-', section_number: @section.number) + basename if prefix_section_number
  basename
end