Class: PlexSymlinker::FileTypes::AudioFile

Inherits:
Object
  • Object
show all
Defined in:
lib/plex_symlinker/file_types/audio_file.rb

Direct Known Subclasses

Mp3, Mp4

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ AudioFile

Returns a new instance of AudioFile.



27
28
29
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 27

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



25
26
27
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 25

def path
  @path
end

Class Method Details

.from_path(path) ⇒ Object



19
20
21
22
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 19

def from_path(path)
  extension = File.extname(path)[1..-1]
  registered_types[extension.to_s]&.new(path) || fail(ArgumentError, "No type handler registered for extension '#{extension}'")
end

.register_type(extension, klass) ⇒ Object



9
10
11
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 9

def register_type(extension, klass)
  registered_types[extension.to_s] = klass
end

.registered_typesObject



5
6
7
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 5

def registered_types
  @registered_types ||= {}
end

.tag_reader(method_name, tag) ⇒ Object



13
14
15
16
17
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 13

def tag_reader(method_name, tag)
  define_method(method_name) do
    tags[tag.to_s]
  end
end

Instance Method Details

#albumObject



35
36
37
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 35

def album
  fail NotImplementedError
end

#album_artistObject



55
56
57
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 55

def album_artist
  fail NotImplementedError
end

#artistObject



51
52
53
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 51

def artist
  fail NotImplementedError
end

#genreObject



39
40
41
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 39

def genre
  fail NotImplementedError
end


67
68
69
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 67

def relative_symlink_dir
  "#{album_artist}/#{album}"
end


71
72
73
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 71

def relative_symlink_path
  "#{relative_symlink_dir}/#{symlink_file_name}"
end


63
64
65
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 63

def symlink_file_name
  File.basename(path)
end

#tagsObject



31
32
33
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 31

def tags
  fail NotImplementedError
end

#titleObject



43
44
45
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 43

def title
  fail NotImplementedError
end

#track_numberObject



59
60
61
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 59

def track_number
  fail NotImplementedError
end

#yearObject



47
48
49
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 47

def year
  fail NotImplementedError
end