Class: Pandora::Station

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Client
Defined in:
lib/pandora/station.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, data = nil) ⇒ Station

Returns a new instance of Station.



22
23
24
25
# File 'lib/pandora/station.rb', line 22

def initialize(user, data = nil)
  @user = user
  load_from_data(data) if data
end

Instance Attribute Details

#allow_add_musicObject (readonly)

Returns the value of attribute allow_add_music.



10
11
12
# File 'lib/pandora/station.rb', line 10

def allow_add_music
  @allow_add_music
end

#allow_deleteObject (readonly)

Returns the value of attribute allow_delete.



10
11
12
# File 'lib/pandora/station.rb', line 10

def allow_delete
  @allow_delete
end

#allow_renameObject (readonly)

Returns the value of attribute allow_rename.



10
11
12
# File 'lib/pandora/station.rb', line 10

def allow_rename
  @allow_rename
end

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/pandora/station.rb', line 10

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/pandora/station.rb', line 10

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/pandora/station.rb', line 10

def name
  @name
end

#quick_mixObject (readonly)

Returns the value of attribute quick_mix.



10
11
12
# File 'lib/pandora/station.rb', line 10

def quick_mix
  @quick_mix
end

#quick_mix_station_idsObject (readonly)

Returns the value of attribute quick_mix_station_ids.



10
11
12
# File 'lib/pandora/station.rb', line 10

def quick_mix_station_ids
  @quick_mix_station_ids
end

#sharedObject (readonly)

Returns the value of attribute shared.



10
11
12
# File 'lib/pandora/station.rb', line 10

def shared
  @shared
end

#sharing_urlObject (readonly)

Returns the value of attribute sharing_url.



10
11
12
# File 'lib/pandora/station.rb', line 10

def sharing_url
  @sharing_url
end

#tokenObject

Returns the value of attribute token.



14
15
16
# File 'lib/pandora/station.rb', line 14

def token
  @token
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/pandora/station.rb', line 10

def url
  @url
end

#userObject (readonly)

Returns the value of attribute user.



13
14
15
# File 'lib/pandora/station.rb', line 13

def user
  @user
end

Instance Method Details

#deleteObject



36
37
38
39
40
41
# 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) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# 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) ⇒ Object



27
28
29
30
31
32
33
34
# 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