Class: Song
- Inherits:
-
Object
- Object
- Song
- Defined in:
- lib/lyrix.rb
Instance Attribute Summary collapse
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#lyrics ⇒ Object
readonly
Returns the value of attribute lyrics.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#fetch_lyrics ⇒ Object
fetches song lyrics, sets @lyrics.
-
#initialize(path) ⇒ Song
constructor
A new instance of Song.
Constructor Details
#initialize(path) ⇒ Song
Returns a new instance of Song.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lyrix.rb', line 24 def initialize(path) @path = path # TODO: need to refactor this with a block # TODO: research namespacing issue for blocks f = TagLib::MPEG::File.new(path) tag = f.id3v2_tag # read basic attributes @title = tag.title @artist = tag.artist # Add lyrics frame uslt = TagLib::ID3v2::UnsynchronizedLyricsFrame.new uslt.text = fetch_lyrics tag.add_frame(uslt) f.save f.close # end end |
Instance Attribute Details
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
22 23 24 |
# File 'lib/lyrix.rb', line 22 def artist @artist end |
#lyrics ⇒ Object (readonly)
Returns the value of attribute lyrics.
22 23 24 |
# File 'lib/lyrix.rb', line 22 def lyrics @lyrics end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
22 23 24 |
# File 'lib/lyrix.rb', line 22 def path @path end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
22 23 24 |
# File 'lib/lyrix.rb', line 22 def title @title end |
Instance Method Details
#fetch_lyrics ⇒ Object
fetches song lyrics, sets @lyrics
47 48 49 |
# File 'lib/lyrix.rb', line 47 def fetch_lyrics @lyrics = WebHelper::fetch_lucky_content_for "#{@title} by #{@artist} lyrics" end |