Class: Nehm::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.



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

def initialize(track)
  @track = track
end

Instance Method Details

#file_pathObject



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

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

#nameObject

Use in Get.dl



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

def name
  'artwork'
end

#suicideObject



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

def suicide
  File.delete(file_path)
end

#urlObject



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

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