Class: EncoderTools::CLI::Subtitles::Offset

Inherits:
Base
  • Object
show all
Defined in:
lib/encoder-tools/cli/subtitles/offset.rb

Constant Summary collapse

NUMBER =
'(\d+|\d*\.\d+)'
HH_MM_SS_OFFSET =
%r{\A(?:(\d\d?):)?(\d\d?):(\d\d?)\Z}
ABSOLUTE_OFFSET =
%r{\A#{NUMBER}\Z}
NEGATIVE_OFFSET =
%r{\A-#{NUMBER}\Z}
POSITIVE_OFFSET =
%r{\A\+#{NUMBER}\Z}
MIN_PER_HOUR =
60
SEC_PER_MIN =
60

Instance Attribute Summary

Attributes inherited from Base

#options, #shell

Instance Method Summary collapse

Methods inherited from Base

#parse, #parser, parser, #read, #write

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from EncoderTools::CLI::Base

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/encoder-tools/cli/subtitles/offset.rb', line 14

def run
  value = if options[:set]
            options[:set]
          elsif options[:add]
            "+#{options[:add]}"
          elsif options[:subtract]
            "-#{options[:subtract]}"
          else
            raise ArgumentError, "Must provide a set, add, or subtract option to determine the offset"
          end

  write offset(read, value)
end