Class: SpotifyWebApi::FollowersObject

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

Overview

FollowersObject 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) ⇒ FollowersObject

Returns a new instance of FollowersObject.



44
45
46
47
# File 'lib/spotify_web_api/models/followers_object.rb', line 44

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

Instance Attribute Details

#hrefString

This will always be set to null, as the Web API does not support it at the moment.

Returns:

  • (String)


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

def href
  @href
end

#totalInteger

The total number of followers.

Returns:

  • (Integer)


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

def total
  @total
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/spotify_web_api/models/followers_object.rb', line 50

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.
  FollowersObject.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/followers_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
41
42
# File 'lib/spotify_web_api/models/followers_object.rb', line 38

def self.nullables
  %w[
    href
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    href
    total
  ]
end