Class: Voot::Vtt
- Inherits:
-
Object
- Object
- Voot::Vtt
- Defined in:
- lib/voot/vtt.rb
Instance Attribute Summary collapse
-
#header ⇒ Object
Returns the value of attribute header.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #cues ⇒ Object
- #has_header? ⇒ Boolean
-
#initialize(options = {}) ⇒ Vtt
constructor
A new instance of Vtt.
- #save ⇒ Object
- #to_webvtt ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Vtt
Returns a new instance of Vtt.
8 9 10 11 |
# File 'lib/voot/vtt.rb', line 8 def initialize( = {}) @path = .fetch(:path) @header = [:header] end |
Instance Attribute Details
#header ⇒ Object
Returns the value of attribute header.
6 7 8 |
# File 'lib/voot/vtt.rb', line 6 def header @header end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/voot/vtt.rb', line 5 def path @path end |
Instance Method Details
#cues ⇒ Object
13 14 15 |
# File 'lib/voot/vtt.rb', line 13 def cues @cues ||= Voot::CueList.new end |
#has_header? ⇒ Boolean
25 26 27 |
# File 'lib/voot/vtt.rb', line 25 def has_header? !header.nil? && header.length > 0 end |
#save ⇒ Object
29 30 31 32 |
# File 'lib/voot/vtt.rb', line 29 def save ensure_destination_directory File.open(path, "w") { |destination| destination.write(to_webvtt) } end |
#to_webvtt ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/voot/vtt.rb', line 17 def to_webvtt if has_header? "WEBVTT #{header}\n\n#{cues.to_webvtt}" else "WEBVTT\n\n#{cues.to_webvtt}" end end |