Class: SrtSubtitleValidator::SrtBlock
- Inherits:
-
Object
- Object
- SrtSubtitleValidator::SrtBlock
- Defined in:
- lib/srt_subtitle_validator/srt_block.rb
Instance Attribute Summary collapse
-
#dialog_number ⇒ Object
Returns the value of attribute dialog_number.
-
#dialog_text ⇒ Object
Returns the value of attribute dialog_text.
-
#dialog_time ⇒ Object
Returns the value of attribute dialog_time.
Instance Method Summary collapse
-
#initialize(*args) ⇒ SrtBlock
constructor
A new instance of SrtBlock.
-
#to_s ⇒ String
Subtitle sequence block.
Constructor Details
#new(text) ⇒ SrtBlock #new(text) ⇒ SrtBlock
Returns a new instance of SrtBlock.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/srt_subtitle_validator/srt_block.rb', line 12 def initialize(*args) case args.count when 1 blok = args[0].split("\n") @dialog_number = blok.shift.to_i @dialog_time = blok.shift @dialog_text = blok.join("\n") when 3 @dialog_number = args.shift.to_i @dialog_time = args.shift @dialog_text = args.shift.strip else raise ArgumentError end end |
Instance Attribute Details
#dialog_number ⇒ Object
Returns the value of attribute dialog_number.
3 4 5 |
# File 'lib/srt_subtitle_validator/srt_block.rb', line 3 def dialog_number @dialog_number end |
#dialog_text ⇒ Object
Returns the value of attribute dialog_text.
3 4 5 |
# File 'lib/srt_subtitle_validator/srt_block.rb', line 3 def dialog_text @dialog_text end |
#dialog_time ⇒ Object
Returns the value of attribute dialog_time.
3 4 5 |
# File 'lib/srt_subtitle_validator/srt_block.rb', line 3 def dialog_time @dialog_time end |
Instance Method Details
#to_s ⇒ String
Returns subtitle sequence block.
29 30 31 |
# File 'lib/srt_subtitle_validator/srt_block.rb', line 29 def to_s [@dialog_number, @dialog_time, @dialog_text].join("\n") + "\n\n" end |