Sha256: d72b6eb449326626092f12fdc1e9f729dd5411512fa80f856053d1423000cf13

Contents?: true

Size: 960 Bytes

Versions: 2

Compression:

Stored size: 960 Bytes

Contents

class Subber::Subtitle
  attr_reader :counter
  attr_reader :start_time
  attr_reader :end_time
  attr_reader :content

  def initialize(attributes)
    @counter = attributes[:counter]
    @start_time = attributes[:start_time]
    @end_time = attributes[:end_time]
    @content = attributes[:content]
  end

  def as_json
    {
      'counter' => counter,
      'start_time' => start_time,
      'end_time' => end_time,
      'content' => content
    }
  end

  # @param miliseconds [Integer] Can be both positive and negative
  # @return [Subber::Subtitle] return a copy with shifted subtitle
  #
  def shift(ms)
    self.class.new(
      counter: counter,
      start_time: start_time + ms,
      end_time: end_time + ms,
      content: content
    )
  end

  # @param miliseconds [Integer] Can be both positive and negative
  # mutates the current subtitle's start and end time by ms
  #
  def shift!(ms)
    @start_time += ms
    @end_time += ms
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
subber-0.1.9 lib/subber/subtitle.rb
subber-0.1.8 lib/subber/subtitle.rb