Sha256: c8e8f1ace4c39ac4ef5d2eb4b394c6848619c23df5ba14a2eb3668762506b2e6
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module SRT class Line attr_accessor :display_coordinates attr_accessor :sequence attr_accessor :start_time attr_accessor :end_time attr_accessor :error attr_writer :text def text @text ||= [] end def initialize(options={}) options.each do |k,v| self.send("#{k}=",v) end end def clone clone = Line.new clone.display_coordinates = display_coordinates clone.sequence = sequence clone.start_time = start_time clone.end_time = end_time clone.error = error clone.text = text.clone clone end def empty? sequence.nil? && start_time.nil? && end_time.nil? && text.empty? end def time_str(subframe_separator=",") [@start_time, @end_time].map { |t| sprintf("%02d:%02d:%02d#{subframe_separator}%s", t / 3600, (t % 3600) / 60, t % 60, sprintf("%.3f", t)[-3, 3]) }.join(" --> ") end def webvtt_time_str time_str(".") end def to_s(time_str_function=:time_str) content = text.empty? ? [''] : text coordinates = display_coordinates ? display_coordinates : "" [sequence, send(time_str_function) + coordinates, content, ""].flatten.join("\n") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
srt-0.1.4 | lib/srt/line.rb |