Module: EasyTag::MP4AttributeAccessors

Includes:
BaseAttributeAccessors
Included in:
MP4Tagger
Defined in:
lib/easytag/attributes/mp4.rb

Instance Method Summary collapse

Methods included from BaseAttributeAccessors

#audio_prop_reader, #cast, #extract, #post_process, #read_audio_property

Instance Method Details

#data_from_item(item, **opts) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/easytag/attributes/mp4.rb', line 16

def data_from_item(item, **opts)
  case opts[:data_type]
  when :string_list
    item.to_string_list
  when :bool
    item.to_bool
  when :int
    item.to_int
  when :int_pair
    item.to_int_pair
  when :cover_art_list
    item.to_cover_art_list.collect { |img| EasyTag::Image.new(img.data) }
  else
    item.to_string_list[0]
  end
end

#item_reader(attr_name, key = nil, **opts) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/easytag/attributes/mp4.rb', line 7

def item_reader(attr_name, key = nil, **opts)
  key = attr_name if key.nil?
  opts[:returns] = opts[:data_type] if opts[:returns].nil? && opts[:cast].nil? # clunky
  define_method(attr_name) do
    v = self.class.read_item(taglib, key, **opts)
    self.class.post_process(v, **opts)
  end
end

#read_item(taglib, key, **opts) ⇒ Object



33
34
35
36
# File 'lib/easytag/attributes/mp4.rb', line 33

def read_item(taglib, key, **opts)
  item = taglib.tag.item_list_map[key]
  data_from_item(item, **opts) unless item.nil?
end