Class: WahWah::Tag
- Inherits:
-
Object
show all
- Defined in:
- lib/wahwah/tag.rb
Constant Summary
collapse
- INTEGER_ATTRIBUTES =
i[disc disc_total track track_total]
- INSPECT_ATTRIBUTES =
i[
title
artist
album
albumartist
composer
track
track_total
genre
year
disc
disc_total
lyrics
duration
bitrate
sample_rate
bit_depth
file_size
]
Instance Method Summary
collapse
Constructor Details
#initialize(io, from_path: false) ⇒ Tag
Returns a new instance of Tag.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/wahwah/tag.rb', line 29
def initialize(io, from_path: false)
@from_path = from_path
@file_size = io.size
@file_io = io
= []
@images_data = []
parse if @file_size > 0
INTEGER_ATTRIBUTES.each do |attr_name|
value = instance_variable_get("@#{attr_name}")&.to_i
instance_variable_set("@#{attr_name}", value)
end
end
|
Instance Method Details
#images ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/wahwah/tag.rb', line 52
def images
return @images_data if @images_data.empty?
@images ||= @images_data.map do |data|
parse_image_data(data)
end
end
|
#inspect ⇒ Object
45
46
47
48
49
50
|
# File 'lib/wahwah/tag.rb', line 45
def inspect
inspect_id = ::Kernel.format "%x", (object_id * 2)
inspect_attributes_values = INSPECT_ATTRIBUTES.map { |attr_name| "#{attr_name}: #{send(attr_name).inspect}" }.join(", ")
"<#{self.class.name}:0x#{inspect_id} #{inspect_attributes_values}>"
end
|