Class: AppleMusic::Artwork

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(props = {}) ⇒ Artwork

Returns a new instance of Artwork.



10
11
12
13
14
15
16
17
18
19
# File 'lib/apple_music/artwork.rb', line 10

def initialize(props = {})
  @bg_color = props['bgColor']
  @height = props['height'] # required
  @width = props['width'] # required
  @text_color1 = props['textColor1']
  @text_color2 = props['textColor2']
  @text_color3 = props['textColor3']
  @text_color4 = props['textColor4']
  @url = props['url'] # required
end

Instance Attribute Details

#bg_colorObject (readonly)

Returns the value of attribute bg_color.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def bg_color
  @bg_color
end

#heightObject (readonly)

Returns the value of attribute height.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def height
  @height
end

#text_color1Object (readonly)

Returns the value of attribute text_color1.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def text_color1
  @text_color1
end

#text_color2Object (readonly)

Returns the value of attribute text_color2.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def text_color2
  @text_color2
end

#text_color3Object (readonly)

Returns the value of attribute text_color3.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def text_color3
  @text_color3
end

#text_color4Object (readonly)

Returns the value of attribute text_color4.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def text_color4
  @text_color4
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def url
  @url
end

#widthObject (readonly)

Returns the value of attribute width.



6
7
8
# File 'lib/apple_music/artwork.rb', line 6

def width
  @width
end

Instance Method Details

#image_url(options = {}) ⇒ Object



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

def image_url(options = {})
  @image_url ||= begin
    width = options[:width] || self.width
    height = options[:height] || self.height
    size = options[:size] || "#{width}x#{height}"
    url.gsub('{w}x{h}', size)
  end
end