Module: Id3Tags
- Defined in:
- lib/id3_tags.rb,
lib/id3_tags/m4a.rb,
lib/id3_tags/mp3.rb,
lib/id3_tags/version.rb,
lib/id3_tags/m4a/fields.rb,
lib/id3_tags/mp3/fields.rb,
lib/id3_tags/fields_accessors.rb,
lib/id3_tags/m4a/fields_getter.rb,
lib/id3_tags/m4a/fields_setter.rb,
lib/id3_tags/mp3/fields_getter.rb,
lib/id3_tags/mp3/fields_setter.rb
Overview
Provides two methods to read and write ID3 metadata from an MP3 or M4A file
Defined Under Namespace
Modules: FieldsAccessors, M4AFields, M4AFieldsGetter, M4AFieldsSetter, MP3Fields, MP3FieldsReader, MP3FieldsWriter Classes: M4A, MPEG
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.mime_type_of(file_path) ⇒ String
Returns the MIME type of the file located at
file_path
. -
.read_tags_from(file_path) ⇒ Hash
Returns a Hash of ID3 attributes stored in the file located at
file_path
. -
.write_tags_to(file_path, attrs = {}) ⇒ Boolean
Stores the
attrs
Hash of ID3 attributes into the file atfile_path
.
Class Method Details
.mime_type_of(file_path) ⇒ String
Returns the MIME type of the file located at file_path
.
66 67 68 69 70 |
# File 'lib/id3_tags.rb', line 66 def self.mime_type_of(file_path) mime_type = MimeMagic.by_magic File.open(file_path) mime_type ||= MimeMagic.by_path file_path mime_type &&= mime_type.type end |
.read_tags_from(file_path) ⇒ Hash
Returns a Hash of ID3 attributes stored in the file located at file_path
.
24 25 26 27 28 29 30 |
# File 'lib/id3_tags.rb', line 24 def self.(file_path) case mime_type_of(file_path) when 'audio/mpeg' then MPEG.new.(file_path) when 'audio/mp4' then M4A.new.(file_path) else {} end end |
.write_tags_to(file_path, attrs = {}) ⇒ Boolean
Stores the attrs
Hash of ID3 attributes into the file at file_path
.
49 50 51 52 53 54 55 |
# File 'lib/id3_tags.rb', line 49 def self.(file_path, attrs = {}) case mime_type_of(file_path) when 'audio/mpeg' then MPEG.new.(file_path, attrs) when 'audio/mp4' then M4A.new.(file_path, attrs) else false end end |