]>
git.r.bdr.sh - rbdr/lyricli.rb/blob - lib/lyricli/lyricli.rb
d546e54d88187c717b01df6cb634213d3febe6ec
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 InvalidLyricsError which means we did not get any valid
13 # artist/song from any of the sources
15 # @raise [Lyricli::Exceptions::InvalidLyricsError] because we found nothing
17 raise Exceptions
::InvalidLyricsError
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 Exceptions
::LyricsNotFoundError
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
?