Class: Mp3file::ID3v1Tag
- Inherits:
-
Object
- Object
- Mp3file::ID3v1Tag
- Defined in:
- lib/mp3file/id3v1_tag.rb
Defined Under Namespace
Classes: ID3v1TagFormat
Constant Summary collapse
- GENRES =
First group is the original spec, the second are Winamp extensions.
%w{ Blues Classic\ Rock Country Dance Disco Funk Grunge Hip-Hop Jazz Metal New\ Age Oldies Other Pop R&B Rap Reggae Rock Techno Industrial Alternative Ska Death\ Metal Pranks Soundtrack Euro-Techno Ambient Trip-Hop Vocal Jazz+Funk Fusion Trance Classical Instrumental Acid House Game Sound\ Clip Gospel Noise AlternRock Bass Soul Punk Space Meditative Instrumental\ Pop Instrumental\ Rock Ethnic Gothic Darkwave Techno-Industrial Electronic Pop-Folk Eurodance Dream Southern\ Rock Comedy Cult Gangsta Top\ 40 Christian\ Rap Pop/Funk Jungle Native\ American Cabaret New\ Wave Psychadelic Rave Showtunes Trailer Lo-Fi Tribal Acid\ Punk Acid\ Jazz Polka Retro Musical Rock\ &\ Roll Hard\ Rock Folk Folk-Rock National\ Folk Swing Fast\ Fusion Bebob Latin Revival Celtic Bluegrass Avantgarde Gothic\ Rock Progressive\ Rock Psychedelic\ Rock Symphonic\ Rock Slow\ Rock Big\ Band Chorus Easy\ Listening Acoustic Humour Speech Chanson Opera Chamber\ Music Sonata Symphony Booty\ Bass Primus Porn\ Groove Satire Slow\ Jam Club Tango Samba Folklore Ballad Power\ Ballad Rhythmic\ Soul Freestyle Duet Punk\ Rock Drum\ Solo A\ capella Euro-House Dance\ Hall }
Instance Attribute Summary collapse
-
#album ⇒ Object
Returns the value of attribute album.
-
#artist ⇒ Object
Returns the value of attribute artist.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#genre ⇒ Object
Returns the value of attribute genre.
-
#genre_id ⇒ Object
Returns the value of attribute genre_id.
-
#title ⇒ Object
Returns the value of attribute title.
-
#track ⇒ Object
Returns the value of attribute track.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ID3v1Tag
constructor
A new instance of ID3v1Tag.
- #load_format(tag_data) ⇒ Object
Constructor Details
#initialize ⇒ ID3v1Tag
Returns a new instance of ID3v1Tag.
68 69 70 |
# File 'lib/mp3file/id3v1_tag.rb', line 68 def initialize @title = @artist = @album = @year = @comment = @track = @genre_id = @genre = nil end |
Instance Attribute Details
#album ⇒ Object
Returns the value of attribute album.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def album @album end |
#artist ⇒ Object
Returns the value of attribute artist.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def artist @artist end |
#comment ⇒ Object
Returns the value of attribute comment.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def comment @comment end |
#genre ⇒ Object
Returns the value of attribute genre.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def genre @genre end |
#genre_id ⇒ Object
Returns the value of attribute genre_id.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def genre_id @genre_id end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def title @title end |
#track ⇒ Object
Returns the value of attribute track.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def track @track end |
#year ⇒ Object
Returns the value of attribute year.
5 6 7 |
# File 'lib/mp3file/id3v1_tag.rb', line 5 def year @year end |
Class Method Details
.parse(io) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mp3file/id3v1_tag.rb', line 38 def self.parse(io) tag_data = nil begin tag_data = ID3v1TagFormat.read(io) rescue BinData::ValidityError => ve raise InvalidID3v1TagError, ve. end if tag_data.nil? nil else new.tap { |rv| rv.load_format(tag_data) } end end |
Instance Method Details
#load_format(tag_data) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mp3file/id3v1_tag.rb', line 54 def load_format(tag_data) @title = tag_data.title @artist = tag_data.artist @album = tag_data.album @year = tag_data.year split_comment = tag_data.comment.split("\x00").reject { |s| s == '' } @comment = split_comment.first || "" if split_comment.size > 1 @track = split_comment.last.bytes.first end @genre_id = tag_data.genre_id @genre = GENRES[tag_data.genre_id] end |