Module: MusicMetadataEnrichment::LastfmHelper

Defined in:
app/helpers/music_metadata_enrichment/lastfm_helper.rb

Instance Method Summary collapse

Instance Method Details

#lastfm_track_text(track, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/music_metadata_enrichment/lastfm_helper.rb', line 4

def lastfm_track_text(track, options = {})
  short = options.has_key?(:short) ? options[:short] : false
  
  artist, name = if track.is_a? MusicTrack
    [track.artist_name, track.name]
  elsif track.is_a?(YearInReviewMusicTrack) || track.is_a?(MusicMetadataEnrichment::GroupYearInReviewTrack)
    [track.artist_name, track.track_name]
  end
  
  text = []
  text << "[artist]#{artist}[/artist]" unless short
  text << "[track artist=#{artist}]#{name}[/track]"
  text.join('')
end