class Pandora::Station

Attributes

allow_add_music[R]
allow_delete[R]
allow_rename[R]
created_at[R]
id[R]
name[R]
quick_mix[R]
quick_mix_station_ids[R]
shared[R]
sharing_url[R]
token[RW]
url[R]
user[R]

Public Class Methods

new(user, data = nil) click to toggle source
# File lib/pandora/station.rb, line 22
def initialize(user, data = nil)
  @user = user
  load_from_data(data) if data
end

Public Instance Methods

delete() click to toggle source
# File lib/pandora/station.rb, line 36
def delete
  # TODO: check allow_delete? force option?
  call 'station.deleteStation', { secure: false, encrypt: true }, {
    stationToken: @token
  }
end
next_songs(audio_formats = Song::DEFAULT_AUDIO_FORMATS) click to toggle source
# File lib/pandora/station.rb, line 43
def next_songs(audio_formats = Song::DEFAULT_AUDIO_FORMATS)
  result = call 'station.getPlaylist', { secure: true, encrypt: true }, {
    stationToken:       @token,
    additionalAudioUrl: audio_formats.join(',')
  }

  result['items'].map do |song_data|
    Song.new(self, song_data, audio_formats)
  end
end
rename(new_name) click to toggle source
# File lib/pandora/station.rb, line 27
def rename(new_name)
  # TODO: check allow_rename? force option?
  result = call 'station.renameStation', { secure: false, encrypt: true }, {
    stationToken: @token,
    stationName:  new_name
  }
  load_from_data(result)
end

Private Instance Methods

load_from_data(data) click to toggle source
# File lib/pandora/station.rb, line 57
def load_from_data(data)
  @id                    = data['stationId']
  @name                  = data['stationName']
  @token                 = data['stationToken']
  @created_at            = Time.at(data['dateCreated']['time'] / 1000.0)
  @url                   = data['stationDetailUrl']
  @shared                = data['isShared']
  @sharing_url           = data['stationSharingUrl']
  @quick_mix             = data['isQuickMix']
  @quick_mix_station_ids = data['quickMixStationIds']
  @allow_rename          = data['allowRename']
  @allow_add_music       = data['allowAddMusic']
  @allow_delete          = data['allowDelete']
end