Class: Lyricli::Lyricli
- Inherits:
-
Object
- Object
- Lyricli::Lyricli
- Defined in:
- lib/lyricli.rb
Instance Method Summary (collapse)
- - (Object) check_params
- - (Object) exit_with_error
- - (Object) get_lyrics
-
- (Lyricli) initialize
constructor
A new instance of Lyricli.
- - (Object) set_current_track
Constructor Details
- (Lyricli) initialize
A new instance of Lyricli
36 37 38 |
# File 'lib/lyricli.rb', line 36 def initialize @source_manager = SourceManager.new end |
Instance Method Details
- (Object) check_params
61 62 63 64 |
# File 'lib/lyricli.rb', line 61 def check_params self.exit_with_error if @current_track[:artist].nil? or @current_track[:artist].empty? self.exit_with_error if @current_track[:song].nil? or @current_track[:song].empty? end |
- (Object) exit_with_error
40 41 42 |
# File 'lib/lyricli.rb', line 40 def exit_with_error abort "Usage: #{$0} artist song" end |
- (Object) get_lyrics
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/lyricli.rb', line 44 def get_lyrics set_current_track check_params engine = LyricsEngine.new(@current_track[:artist], @current_track[:song]) begin engine.get_lyrics rescue LyricsNotFoundException "Lyrics not found :(" end end |
- (Object) set_current_track
57 58 59 |
# File 'lib/lyricli.rb', line 57 def set_current_track @current_track = @source_manager.current_track end |