Class: Vagalume::LyricFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/vagalume/lyric_formatter.rb

Instance Method Summary collapse

Instance Method Details

#format(search, options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/vagalume/lyric_formatter.rb', line 3

def format(search, options)
  return "No lyric found" if search.not_found?

  original_song = search.song

  if options[:translation]
    translated_song = search.translations.with_language(Vagalume::Language::PORTUGUESE)
    return "No translation found" if translated_song.nil?
    return formatted_song_with_transaction(original_song, translated_song)
  end

  "\n\n#{original_song.name}\n\n#{original_song.lyric}"
end