Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,24 @@ To parse a webvtt file:
require "webvtt"

webvtt = WebVTT.read("path/sub.vtt")

webvtt.cues.each do |cue|
puts "identifier: #{cue.identifier}"
puts "Start: #{cue.start}"
puts "End: #{cue.end}"
puts "Start: #{cue.start.to_s}, #{cue.start.to_f} seconds"
puts "End: #{cue.end.to_s}, #{cue.end.to_f} seconds"
puts "Style: #{cue.style.inspect}"
puts "Text: #{cue.text}"
puts "Plain text: #{cue.plain_text}" # text without style tags if any
puts "--"
end
```

To read from a string:

```ruby
webvtt == WebVTT.from_blog(string)
```

## Converting from SRT

You can also convert an SRT file to a standard WebVTT file:
Expand Down