]> git.r.bdr.sh - rbdr/lyricli.rb/blob - lib/lyricli/lyricli.rb
06302f50948080335de90fd65303485826ba4d1f
[rbdr/lyricli.rb] / lib / lyricli / lyricli.rb
1 module Lyricli
2 class Lyricli
3
4 def initialize
5 @source_manager = SourceManager.new
6 end
7
8 def exit_with_error
9 raise InvalidLyrics
10 end
11
12 def get_lyrics
13 set_current_track
14 check_params
15
16 engine = LyricsEngine.new(@current_track[:artist], @current_track[:song])
17
18 begin
19 engine.get_lyrics
20 rescue LyricsNotFoundException
21 "Lyrics not found :("
22 end
23 end
24
25 def set_current_track
26 @current_track = @source_manager.current_track
27 end
28
29 def check_params
30 self.exit_with_error if @current_track[:artist].nil? or @current_track[:artist].empty?
31 self.exit_with_error if @current_track[:song].nil? or @current_track[:song].empty?
32 end
33 end
34 end