Class: Id3Tags::MPEG

Inherits:
Object
  • Object
show all
Includes:
FieldsAccessors, MP3Fields, MP3FieldsReader, MP3FieldsWriter
Defined in:
lib/id3_tags/mp3.rb

Instance Method Summary collapse

Instance Method Details

#read_tags_from(file_path) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/id3_tags/mp3.rb', line 13

def read_tags_from(file_path)
  attrs = {}
  TagLib::MPEG::File.open(file_path) do |file|
    attrs.merge! get_tag_fields(file)
    attrs.merge! get_audio_properties_fields(file)
    attrs.merge! get_id3v2_tag_fields(file)
  end
  attrs.symbolize_keys
end

#write_tags_to(file_path, attrs = {}) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/id3_tags/mp3.rb', line 23

def write_tags_to(file_path, attrs = {})
  attrs.symbolize_keys!
  TagLib::MPEG::File.open(file_path) do |file|
    set_tag_fields!(file, attrs)
    set_id3v2_tag_fields!(file, attrs)
    file.save
  end
end