class RakeMKV::Command

Command Object

Attributes

command_line_class[R]
path[R]

Public Class Methods

new(path:, command_line_class: Terrapin::CommandLine) click to toggle source

Initialize with path

# File lib/rakemkv/command.rb, line 4
def initialize(path:, command_line_class: Terrapin::CommandLine)
  @path = path
  @command_line_class =  command_line_class
end

Public Instance Methods

info(options = {}) click to toggle source

Call info command on disc

# File lib/rakemkv/command.rb, line 10
def info(options = {})
  arguments = build_arguments(options)
  @info ||= execute("info #{path}", arguments)
end
mkv(title_id, destination, options = {}) click to toggle source

Call mkv command on disc

# File lib/rakemkv/command.rb, line 16
def mkv(title_id, destination, options = {})
  arguments = build_arguments(options)
  @mkv ||= execute("mkv #{path} #{title_id} #{destination}", arguments)
end

Private Instance Methods

binary() click to toggle source
# File lib/rakemkv/command.rb, line 36
def binary
  "#{RakeMKV.config.binary} -r"
end
build_arguments(options) click to toggle source
# File lib/rakemkv/command.rb, line 25
def build_arguments(options)
  options.map do |key,value|
    "--#{key}=#{value}"
  end.join(" ")
end
execute(command, arguments) click to toggle source
# File lib/rakemkv/command.rb, line 31
def execute(command, arguments)
  full_command = [command, arguments].reject(&:empty?).join(" ")
  command_line_class.new(binary, full_command).run
end