module SubtitleConvertorCommandLine
Public Class Methods
error(message)
click to toggle source
# File lib/subtitle_converter/subtitle_convertor_command_line.rb, line 5 def self.error message puts message usage end
process(command_line_arguments)
click to toggle source
# File lib/subtitle_converter/subtitle_convertor_command_line.rb, line 18 def self.process(command_line_arguments) return error "convert_subtitle: missing arguments!\n" if command_line_arguments.empty? return error "convert_subtitle: too much arguments!\n" if command_line_arguments.size > 2 source_file = command_line_arguments[0] target_file = command_line_arguments[1] || target_file_from_source(source_file) SubtitleConvertor.new.from(source_file).to(target_file).convert puts "Finished converting subtitle" end
target_file_from_source(source_file)
click to toggle source
# File lib/subtitle_converter/subtitle_convertor_command_line.rb, line 14 def self.target_file_from_source source_file File.basename(source_file, File.extname(source_file)) + ".srt" end
usage()
click to toggle source
# File lib/subtitle_converter/subtitle_convertor_command_line.rb, line 10 def self.usage puts "usage: convert source [destination]" end