Class: PlexSymlinker::FileTypes::AudioFile
- Inherits:
-
Object
- Object
- PlexSymlinker::FileTypes::AudioFile
- Defined in:
- lib/plex_symlinker/file_types/audio_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
- .from_path(path) ⇒ Object
- .register_type(extension, klass) ⇒ Object
- .registered_types ⇒ Object
- .tag_reader(method_name, tag) ⇒ Object
Instance Method Summary collapse
- #album ⇒ Object
- #album_artist ⇒ Object
- #artist ⇒ Object
- #genre ⇒ Object
-
#initialize(path) ⇒ AudioFile
constructor
A new instance of AudioFile.
- #relative_symlink_dir ⇒ Object
- #relative_symlink_path ⇒ Object
- #symlink_file_name ⇒ Object
- #tags ⇒ Object
- #title ⇒ Object
- #track_number ⇒ Object
- #year ⇒ Object
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
#path ⇒ Object (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_types ⇒ Object
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 [tag.to_s] end end |
Instance Method Details
#album ⇒ Object
35 36 37 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 35 def album fail NotImplementedError end |
#album_artist ⇒ Object
55 56 57 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 55 def album_artist fail NotImplementedError end |
#artist ⇒ Object
51 52 53 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 51 def artist fail NotImplementedError end |
#genre ⇒ Object
39 40 41 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 39 def genre fail NotImplementedError end |
#relative_symlink_dir ⇒ Object
67 68 69 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 67 def relative_symlink_dir "#{album_artist}/#{album}" end |
#relative_symlink_path ⇒ Object
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 |
#symlink_file_name ⇒ Object
63 64 65 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 63 def symlink_file_name File.basename(path) end |
#tags ⇒ Object
31 32 33 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 31 def fail NotImplementedError end |
#title ⇒ Object
43 44 45 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 43 def title fail NotImplementedError end |
#track_number ⇒ Object
59 60 61 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 59 def track_number fail NotImplementedError end |
#year ⇒ Object
47 48 49 |
# File 'lib/plex_symlinker/file_types/audio_file.rb', line 47 def year fail NotImplementedError end |