Class: Artwork

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

Overview

Artwork objects contains all needed information of track’s artwork

Instance Method Summary collapse

Constructor Details

#initialize(track) ⇒ Artwork

Returns a new instance of Artwork.



3
4
5
# File 'lib/nehm/artwork.rb', line 3

def initialize(track)
  @track = track
end

Instance Method Details

#file_pathObject



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

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

#nameObject

Use in Get.dl



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

def name
  'artwork'
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