Class: SpotifyWebApi::ImageObject
- Defined in:
- lib/spotify_web_api/models/image_object.rb
Overview
ImageObject Model.
Instance Attribute Summary collapse
-
#height ⇒ Integer
The image height in pixels.
-
#url ⇒ String
The source URL of the image.
-
#width ⇒ Integer
The image width in pixels.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(url = nil, height = nil, width = nil) ⇒ ImageObject
constructor
A new instance of ImageObject.
Methods inherited from BaseModel
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
#height ⇒ Integer
The image height in pixels.
18 19 20 |
# File 'lib/spotify_web_api/models/image_object.rb', line 18 def height @height end |
#url ⇒ String
The source URL of the image.
14 15 16 |
# File 'lib/spotify_web_api/models/image_object.rb', line 14 def url @url end |
#width ⇒ Integer
The image width in pixels.
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
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 |
.optionals ⇒ Object
An array for optional fields
34 35 36 |
# File 'lib/spotify_web_api/models/image_object.rb', line 34 def self.optionals [] end |