Class: Nehm::Artwork

Inherits:
Object
  • Object
show all
Defined in:
lib/nehm/artwork.rb

Overview

Artwork objects contains all information of track’s artwork

Instance Method Summary collapse

Constructor Details

#initialize(track) ⇒ Artwork

Returns a new instance of Artwork.



8
9
10
# File 'lib/nehm/artwork.rb', line 8

def initialize(track)
  @track = track
end

Instance Method Details

#file_pathObject



12
13
14
# File 'lib/nehm/artwork.rb', line 12

def file_path
  File.join('/tmp', "#{@track.id}.jpg")
end

#suicideObject



16
17
18
# File 'lib/nehm/artwork.rb', line 16

def suicide
  File.delete(file_path)
end

#urlObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/nehm/artwork.rb', line 20

def url
  hash = @track.hash
  url =
    if hash['artwork_url'].nil?
      hash['user']['avatar_url']
    else
      hash['artwork_url']
    end
  url.sub('large', 't500x500')
end