Class: SpotifyWebApi::PlaylistTracksRefObject

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

Overview

PlaylistTracksRefObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(href = SKIP, total = SKIP) ⇒ PlaylistTracksRefObject

Returns a new instance of PlaylistTracksRefObject.



42
43
44
45
# File 'lib/spotify_web_api/models/playlist_tracks_ref_object.rb', line 42

def initialize(href = SKIP, total = SKIP)
  @href = href unless href == SKIP
  @total = total unless total == SKIP
end

Instance Attribute Details

#hrefString

A link to the Web API endpoint where full details of the playlist’s tracks can be retrieved.

Returns:

  • (String)


15
16
17
# File 'lib/spotify_web_api/models/playlist_tracks_ref_object.rb', line 15

def href
  @href
end

#totalInteger

Number of tracks in the playlist.

Returns:

  • (Integer)


19
20
21
# File 'lib/spotify_web_api/models/playlist_tracks_ref_object.rb', line 19

def total
  @total
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/spotify_web_api/models/playlist_tracks_ref_object.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  href = hash.key?('href') ? hash['href'] : SKIP
  total = hash.key?('total') ? hash['total'] : SKIP

  # Create object from extracted values.
  PlaylistTracksRefObject.new(href,
                              total)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
# File 'lib/spotify_web_api/models/playlist_tracks_ref_object.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['href'] = 'href'
  @_hash['total'] = 'total'
  @_hash
end

.nullablesObject

An array for nullable fields



38
39
40
# File 'lib/spotify_web_api/models/playlist_tracks_ref_object.rb', line 38

def self.nullables
  []
end

.optionalsObject

An array for optional fields



30
31
32
33
34
35
# File 'lib/spotify_web_api/models/playlist_tracks_ref_object.rb', line 30

def self.optionals
  %w[
    href
    total
  ]
end