Sha256: 4d32be8d2fa74d7b75368ba66a46a604096d0ecae8edde8e67b1d2147b16d880

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

module EncoderTools
  class CLI
    module Subtitles
      class Offset < Base
        def run
          output << offset(parse(input.read), options[:offset]).to_s
        end

        protected
          def offset(list, offset)
            list.offset = parse_offset(list, offset)
            return list
          end

          def parse_offset(list, offset)
            case offset
            when Fixnum
              offset
            when /^\+(\d+)$/
              list.offset + $1.to_i
            when /^-(\d+)$/
              list.offset - $1.to_i
            when /^\d+$/
              offset.to_i
            end
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
encoder-tools-0.0.2 lib/encoder-tools/cli/subtitles/offset.rb