module EasyTag::BaseAttributeAccessors
Public Instance Methods
audio_prop_reader(attr_name, prop_name = nil, **opts)
click to toggle source
# File lib/easytag/attributes/base.rb, line 4 def audio_prop_reader(attr_name, prop_name = nil, **opts) prop_name = attr_name if prop_name.nil? define_method(attr_name) do v = self.class.read_audio_property(taglib, prop_name) self.class.post_process(v, opts) end end
cast(data, key, **opts)
click to toggle source
# File lib/easytag/attributes/base.rb, line 12 def cast(data, key, **opts) case opts[key] when :int data.to_i when :int_pair Utilities.get_int_pair(data) when :datetime Utilities.get_datetime(data.to_s) when :list Array(data) when :bool [1, '1', true].include?(data) else data end end
extract(data, **opts)
click to toggle source
# File lib/easytag/attributes/base.rb, line 29 def extract(data, **opts) if opts.has_key?(:extract_list_pos) data = data[opts[:extract_list_pos]] end data end
post_process(data, opts)
click to toggle source
# File lib/easytag/attributes/base.rb, line 36 def post_process(data, opts) data = cast(data, :cast, **opts) data = extract(data, **opts) cast(data, :returns, **opts) end
read_audio_property(taglib, key)
click to toggle source
# File lib/easytag/attributes/base.rb, line 42 def read_audio_property(taglib, key) taglib.audio_properties.send(key) end