Sha256: cb01d3c1229955875731ad1c51040aaa7ba27b62871bd192913bf6a499586d66
Contents?: true
Size: 1000 Bytes
Versions: 1
Compression:
Stored size: 1000 Bytes
Contents
module EncoderTools module Subtitles class Subtitle attr_accessor :range, :text def initialize(range, text) @range, @text = range, text end def offset range.begin end def offset=(offset) self.range = offset..(offset + duration) end def duration range.end - range.begin end def duration=(duration) self.range = offset..(offset + duration) end def ==(other) other.is_a?(self.class) && other.range == self.range && other.text == self.text end def to_s "#{timestamp range.begin} --> #{timestamp range.end}\n#{text}" end private def timestamp(value) seconds = value.to_i millis = ((value - seconds) * 1000).to_i minutes, seconds = seconds.divmod(60) hours, minutes = minutes.divmod(60) "%02d:%02d:%02d,%03d" % [hours, minutes, seconds, millis] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
encoder-tools-0.0.2 | lib/encoder-tools/subtitles/subtitle.rb |