Class: SpotifyWebApi::ContextObject
- Defined in:
- lib/spotify_web_api/models/context_object.rb
Overview
ContextObject Model.
Instance Attribute Summary collapse
-
#external_urls ⇒ ExternalUrlObject
External URLs for this context.
-
#href ⇒ String
A link to the Web API endpoint providing full details of the track.
-
#type ⇒ String
The object type, e.g.
-
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the context.
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(type = SKIP, href = SKIP, external_urls = SKIP, uri = SKIP) ⇒ ContextObject
constructor
A new instance of ContextObject.
Methods inherited from BaseModel
Constructor Details
#initialize(type = SKIP, href = SKIP, external_urls = SKIP, uri = SKIP) ⇒ ContextObject
Returns a new instance of ContextObject.
54 55 56 57 58 59 |
# File 'lib/spotify_web_api/models/context_object.rb', line 54 def initialize(type = SKIP, href = SKIP, external_urls = SKIP, uri = SKIP) @type = type unless type == SKIP @href = href unless href == SKIP @external_urls = external_urls unless external_urls == SKIP @uri = uri unless uri == SKIP end |
Instance Attribute Details
#external_urls ⇒ ExternalUrlObject
External URLs for this context.
22 23 24 |
# File 'lib/spotify_web_api/models/context_object.rb', line 22 def external_urls @external_urls end |
#href ⇒ String
A link to the Web API endpoint providing full details of the track.
18 19 20 |
# File 'lib/spotify_web_api/models/context_object.rb', line 18 def href @href end |
#type ⇒ String
The object type, e.g. “artist”, “playlist”, “album”, “show”.
14 15 16 |
# File 'lib/spotify_web_api/models/context_object.rb', line 14 def type @type end |
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the context.
27 28 29 |
# File 'lib/spotify_web_api/models/context_object.rb', line 27 def uri @uri end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/spotify_web_api/models/context_object.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash.key?('type') ? hash['type'] : SKIP href = hash.key?('href') ? hash['href'] : SKIP external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls'] uri = hash.key?('uri') ? hash['uri'] : SKIP # Create object from extracted values. ContextObject.new(type, href, external_urls, uri) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/spotify_web_api/models/context_object.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['href'] = 'href' @_hash['external_urls'] = 'external_urls' @_hash['uri'] = 'uri' @_hash end |
.nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/spotify_web_api/models/context_object.rb', line 50 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 43 44 45 46 47 |
# File 'lib/spotify_web_api/models/context_object.rb', line 40 def self.optionals %w[ type href external_urls uri ] end |