Class: Subber::Parser::Vtt
Constant Summary collapse
- SUBTITLE_REGEX =
/(\d*)\n?(^\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}$)\n?(.*)/m
- COUNTER_REGEX =
/\d+/
- TIME_RANGE_REGEX =
/(^\d{0,2}:?\d{2}:\d{2}\.\d{3})\s-->\s(\d{0,2}:?\d{2}:\d{2}\.\d{3}$)/
- TIMECODE_REGEX =
/(^\d{0,2}):?(\d{2}):(\d{2})\.(\d{3})/
- CUE_DELIMITER_REGEX =
/\n\n/
- WINDOW_LINE_BREAK_REGEX =
/\r/
- BYTE_ORDER_MARK_STRING =
"\xEF\xBB\xBF"
- INVALID_CUE_START_STRINGS =
%w(WEBVTT NOTE STYLE REGION)
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Class Method Details
.parse(file_content) ⇒ Array<Subber::Subtitle>
17 18 19 20 21 22 23 24 |
# File 'lib/subber/parser/vtt.rb', line 17 def parse(file_content) file_content = remove_window_line_break(file_content) cues = extract_cues(file_content) cues.map.with_index do |cue, index| convert_cue_to_subtitle(cue, index) end end |