Class: CloudinarySubtitlesEmbedder::SubtitleLine
- Inherits:
-
Object
- Object
- CloudinarySubtitlesEmbedder::SubtitleLine
- Defined in:
- lib/cloudinary_subtitles_embedder/subtitle_line.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #display_options ⇒ Object
-
#initialize(subtitle_options, general_display_options = nil) ⇒ SubtitleLine
constructor
A new instance of SubtitleLine.
- #to_s ⇒ Object
Constructor Details
#initialize(subtitle_options, general_display_options = nil) ⇒ SubtitleLine
Returns a new instance of SubtitleLine.
14 15 16 17 18 19 |
# File 'lib/cloudinary_subtitles_embedder/subtitle_line.rb', line 14 def initialize(, = nil) self.start_time = ["start-timing"] self.end_time = ["end-timing"] self.text = ["text"] @display_options = end |
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
4 5 6 |
# File 'lib/cloudinary_subtitles_embedder/subtitle_line.rb', line 4 def end_time @end_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
4 5 6 |
# File 'lib/cloudinary_subtitles_embedder/subtitle_line.rb', line 4 def start_time @start_time end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/cloudinary_subtitles_embedder/subtitle_line.rb', line 4 def text @text end |
Class Method Details
.font ⇒ Object
10 11 12 |
# File 'lib/cloudinary_subtitles_embedder/subtitle_line.rb', line 10 def self.font 'Roboto_34px_bold' end |
Instance Method Details
#display_options ⇒ Object
6 7 8 |
# File 'lib/cloudinary_subtitles_embedder/subtitle_line.rb', line 6 def @display_options || %w(co_white g_south y_20) end |
#to_s ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cloudinary_subtitles_embedder/subtitle_line.rb', line 21 def to_s = .join(',') # see https://support.cloudinary.com/hc/en-us/community/posts/200788162-Using-special-characters-in-Text-overlaying- escaped_text = ERB::Util.url_encode(text) .gsub('%2C', '%252C') start_time_sec = CloudinarySubtitlesEmbedder::SubtitleTime.to_seconds(start_time) end_time_sec = CloudinarySubtitlesEmbedder::SubtitleTime.to_seconds(end_time) "/l_text:#{self.class.font}:#{escaped_text},so_#{start_time_sec},eo_#{end_time_sec}" + (.empty? ? '' : ',') + end |