Class: SpotifyWebApi::ImageObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/spotify_web_api/models/image_object.rb

Overview

ImageObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(url = nil, height = nil, width = nil) ⇒ ImageObject

Returns a new instance of ImageObject.



46
47
48
49
50
# File 'lib/spotify_web_api/models/image_object.rb', line 46

def initialize(url = nil, height = nil, width = nil)
  @url = url
  @height = height
  @width = width
end

Instance Attribute Details

#heightInteger

The image height in pixels.

Returns:

  • (Integer)


18
19
20
# File 'lib/spotify_web_api/models/image_object.rb', line 18

def height
  @height
end

#urlString

The source URL of the image.

Returns:

  • (String)


14
15
16
# File 'lib/spotify_web_api/models/image_object.rb', line 14

def url
  @url
end

#widthInteger

The image width in pixels.

Returns:

  • (Integer)


22
23
24
# File 'lib/spotify_web_api/models/image_object.rb', line 22

def width
  @width
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/spotify_web_api/models/image_object.rb', line 53

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  url = hash.key?('url') ? hash['url'] : nil
  height = hash.key?('height') ? hash['height'] : nil
  width = hash.key?('width') ? hash['width'] : nil

  # Create object from extracted values.
  ImageObject.new(url,
                  height,
                  width)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/spotify_web_api/models/image_object.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['url'] = 'url'
  @_hash['height'] = 'height'
  @_hash['width'] = 'width'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
42
43
44
# File 'lib/spotify_web_api/models/image_object.rb', line 39

def self.nullables
  %w[
    height
    width
  ]
end

.optionalsObject

An array for optional fields



34
35
36
# File 'lib/spotify_web_api/models/image_object.rb', line 34

def self.optionals
  []
end