]>
git.r.bdr.sh - rbdr/lyricli.rb/blob - lib/lyricli/lyricli.rb
518db2df8d380f7671d58c8986c931eb6b8afa1c
3 # This class has the basic logic for extracting the lyrics and controlling the
7 # Constructor, initializes `@source_manager`
9 @source_manager = SourceManager
.new
12 # Raises an InvalidLyricsException which means we did not get any valid
13 # artist/song from any of the sources
15 # @raise [Lyricli::InvalidLyricsException] because we found nothing
17 raise InvalidLyricsException
20 # Extracts the current track, validates it and requests the lyrics from our
23 # @return [String] the found lyrics, or a string indicating none were found
28 engine
= LyricsEngine
.new(@current_track[:artist], @current_track[:song])
32 rescue LyricsNotFoundException
37 # Set the `@current_track` instance variable by asking the SourceManager for
40 @current_track = @source_manager.current_track
43 # Exits with error when there is an empty field from the current track.
45 self.exit_with_error
if @current_track[:artist].nil? or @current_track[:artist].empty
?
46 self.exit_with_error
if @current_track[:song].nil? or @current_track[:song].empty
?