Class: Pandoru::Models::Station

Inherits:
Base
  • Object
show all
Defined in:
lib/pandoru/models/station.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

date_field, field, fields, from_json_list, #initialize, #inspect, #populate_from_json, #to_h

Constructor Details

This class inherits a constructor from Pandoru::Models::Base

Instance Attribute Details

#feedbackObject

Populated only by getStation with includeExtendedAttributes; nil for stations returned in a getStationList response.



115
116
117
# File 'lib/pandoru/models/station.rb', line 115

def feedback
  @feedback
end

#seedsObject

Populated only by getStation with includeExtendedAttributes; nil for stations returned in a getStationList response.



115
116
117
# File 'lib/pandoru/models/station.rb', line 115

def seeds
  @seeds
end

Class Method Details

.from_json(api_client, data) ⇒ Object



122
123
124
125
126
127
128
# File 'lib/pandoru/models/station.rb', line 122

def self.from_json(api_client, data)
  station = super
  return station unless station && data
  station.seeds    = StationSeeds.from_json(api_client, data['music'])
  station.feedback = StationFeedback.from_json(api_client, data['feedback'])
  station
end

Instance Method Details

#add_seed(music_token) ⇒ Object



170
171
172
173
174
175
# File 'lib/pandoru/models/station.rb', line 170

def add_seed(music_token)
  return false unless allow_add_music && @api_client
  # add_music expects (music_token, station_token) — music token first.
  @api_client.add_music(music_token, token)
  true
end

#deleteObject



164
165
166
167
168
# File 'lib/pandoru/models/station.rb', line 164

def delete
  return false unless allow_delete && @api_client
  @api_client.delete_station(token)
  true
end

#get_playlistObject



152
153
154
155
# File 'lib/pandoru/models/station.rb', line 152

def get_playlist
  return nil unless @api_client
  @api_client.get_playlist(token)
end

#rename(new_name) ⇒ Object



157
158
159
160
161
162
# File 'lib/pandoru/models/station.rb', line 157

def rename(new_name)
  return false unless allow_rename && @api_client
  @api_client.rename_station(token, new_name)
  @name = new_name
  true
end

#seed_artistsObject

Seed accessors that are always safe to call (empty array when the station was loaded without extended attributes).



132
133
134
# File 'lib/pandoru/models/station.rb', line 132

def seed_artists
  seeds&.artists || []
end

#seed_genresObject



140
141
142
# File 'lib/pandoru/models/station.rb', line 140

def seed_genres
  seeds&.genres || []
end

#seed_songsObject



136
137
138
# File 'lib/pandoru/models/station.rb', line 136

def seed_songs
  seeds&.songs || []
end

#thumbs_downObject



148
149
150
# File 'lib/pandoru/models/station.rb', line 148

def thumbs_down
  feedback&.thumbs_down || []
end

#thumbs_upObject



144
145
146
# File 'lib/pandoru/models/station.rb', line 144

def thumbs_up
  feedback&.thumbs_up || []
end