Class: RakeMKV::Disc

Inherits:
Object
  • Object
show all
Defined in:
lib/rakemkv/disc.rb

Overview

Disc object

Constant Summary collapse

DEFAULT_MINLENGTH =
120

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location:, destination: Dir.pwd, minlength: DEFAULT_MINLENGTH, parser_class: RakeMKV::Parser) ⇒ Disc

Initialize disc



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rakemkv/disc.rb', line 8

def initialize(
  location:,
  destination: Dir.pwd,
  minlength: DEFAULT_MINLENGTH,
  parser_class: RakeMKV::Parser
)
  @location = location
  @destination = destination
  @minlength = minlength
  @parser_class = parser_class
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Meta disc information



56
57
58
# File 'lib/rakemkv/disc.rb', line 56

def method_missing(method, *args)
  info.cinfo[method.to_sym] || super
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/rakemkv/disc.rb', line 3

def location
  @location
end

Instance Method Details

#destination_with_nameObject



60
61
62
# File 'lib/rakemkv/disc.rb', line 60

def destination_with_name
  File.join(destination, filesafe_name)
end

#filesafe_nameObject



46
47
48
# File 'lib/rakemkv/disc.rb', line 46

def filesafe_name
 info.cinfo[:name].downcase.gsub(/[\/ ]/ , "_")
end

#infoObject

parse file info from command



36
37
38
# File 'lib/rakemkv/disc.rb', line 36

def info
  @info ||= parser_class.new command.info(arguments)
end

#pathObject

Get path from location



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rakemkv/disc.rb', line 21

def path
  if location =~ /^\/dev/
    "dev:#{location}"
  elsif location =~ /iso$/
    "iso:#{location}"
  elsif location.is_a?(Integer)
    "disc:#{location}"
  elsif location =~ /^disc/
    location
  else
    raise RuntimeError
  end
end

#titlesObject

Get titles for disc



51
52
53
# File 'lib/rakemkv/disc.rb', line 51

def titles
  RakeMKV::Titles.new(build_titles)
end

#transcode!(title_id: titles.longest.id) ⇒ Object

Transcode information on disc



41
42
43
44
# File 'lib/rakemkv/disc.rb', line 41

def transcode!(title_id: titles.longest.id)
  check_and_create_destination
  command.mkv(title_id, destination_with_name, arguments)
end