Class: Mp3Parser
- Inherits:
-
Object
- Object
- Mp3Parser
- Defined in:
- lib/lyrics_ebook/mp3_parser.rb
Instance Attribute Summary collapse
-
#lyrics ⇒ Object
Returns the value of attribute lyrics.
Instance Method Summary collapse
-
#initialize ⇒ Mp3Parser
constructor
A new instance of Mp3Parser.
- #parse(filename) ⇒ Object
Constructor Details
#initialize ⇒ Mp3Parser
Returns a new instance of Mp3Parser.
7 8 9 |
# File 'lib/lyrics_ebook/mp3_parser.rb', line 7 def initialize @lyrics= [] end |
Instance Attribute Details
#lyrics ⇒ Object
Returns the value of attribute lyrics.
5 6 7 |
# File 'lib/lyrics_ebook/mp3_parser.rb', line 5 def lyrics @lyrics end |
Instance Method Details
#parse(filename) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lyrics_ebook/mp3_parser.rb', line 11 def parse filename if File.directory?(filename) Dir.foreach(filename) do |file2| unless ['.','..'].include?(file2) f= File.join(filename,file2) parse f end end return end ext=File.extname(filename) if (ext=='.mp3') Mp3Info.open(filename) do |mp3| if mp3.tag.title lyric=Lyric.new(:artist=>mp3.tag.artist, :album=>mp3.tag.album, :title=>mp3.tag.title, :tracknum=>mp3.tag.tracknum, :mp3_filename=>filename) @lyrics << lyric puts "Added : #{lyric.to_s}" end end end end |