Class: WebVTT::File
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Blob
Instance Method Summary collapse
-
#initialize(webvtt_file) ⇒ File
constructor
A new instance of File.
- #save(output = nil) ⇒ Object
Methods inherited from Blob
#actual_total_length, #parse, #to_webvtt, #total_length
Constructor Details
#initialize(webvtt_file) ⇒ File
86 87 88 89 90 91 92 93 94 |
# File 'lib/webvtt/parser.rb', line 86 def initialize(webvtt_file) if !::File.exist?(webvtt_file) raise InputError, "WebVTT file not found" end @path = webvtt_file @filename = ::File.basename(@path) super(::File.read(webvtt_file)) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
84 85 86 |
# File 'lib/webvtt/parser.rb', line 84 def filename @filename end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
84 85 86 |
# File 'lib/webvtt/parser.rb', line 84 def path @path end |
Instance Method Details
#save(output = nil) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/webvtt/parser.rb', line 96 def save(output=nil) output ||= @path.gsub(".srt", ".vtt") ::File.open(output, "w") do |f| f.write(to_webvtt) end return output end |