Class: DuoSplitter::Models::Sentence
- Inherits:
-
Object
- Object
- DuoSplitter::Models::Sentence
- Defined in:
- lib/duo_splitter/models/sentence.rb
Instance Attribute Summary collapse
-
#audio_path ⇒ Object
Returns the value of attribute audio_path.
-
#blank_audio_path ⇒ Object
Returns the value of attribute blank_audio_path.
-
#end_pos ⇒ Object
readonly
Returns the value of attribute end_pos.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#source_audio_path ⇒ Object
Returns the value of attribute source_audio_path.
-
#start_pos ⇒ Object
readonly
Returns the value of attribute start_pos.
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(number:, start_pos:, end_pos:, section:) ⇒ Sentence
constructor
A new instance of Sentence.
- #intro? ⇒ Boolean
- #output_basename(ext:, prefix_section_number: true, blank: false, concatenated: false) ⇒ Object
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_path ⇒ Object
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_path ⇒ Object
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_pos ⇒ Object (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 |
#number ⇒ Object (readonly)
Returns the value of attribute number.
6 7 8 |
# File 'lib/duo_splitter/models/sentence.rb', line 6 def number @number end |
#section ⇒ Object (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_path ⇒ Object
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_pos ⇒ Object (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
#duration ⇒ Object
17 18 19 |
# File 'lib/duo_splitter/models/sentence.rb', line 17 def duration Float(@end_pos) - Float(@start_pos) end |
#intro? ⇒ 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 |