Class: Grooveshark::Broadcast

Inherits:
Object
  • Object
show all
Defined in:
lib/grooveshark/broadcast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, broadcast_id = nil, data = nil) ⇒ Broadcast

Returns a new instance of Broadcast.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/grooveshark/broadcast.rb', line 8

def initialize(client, broadcast_id=nil, data=nil)
  @client = client

  if broadcast_id
    @id = broadcast_id
    reload_status()
  elsif data
    @id          = data['broadcast_id'] || broadcast_id
    @name        = data['name']
    @is_playing  = data['is_playing'] == 1 ? true : false
    @is_active   = data['is_active']
    @active_song = Song.new(data['active_song'])
    @next_song   = Song.new(data['next_song'])
    @usernames   = data['usernames']
    @user_ids    = data['owner_user_i_ds']
  end
end

Instance Attribute Details

#active_songObject (readonly)

Returns the value of attribute active_song.



6
7
8
# File 'lib/grooveshark/broadcast.rb', line 6

def active_song
  @active_song
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/grooveshark/broadcast.rb', line 3

def id
  @id
end

#is_activeObject (readonly)

Returns the value of attribute is_active.



4
5
6
# File 'lib/grooveshark/broadcast.rb', line 4

def is_active
  @is_active
end

#is_playingObject (readonly)

Returns the value of attribute is_playing.



4
5
6
# File 'lib/grooveshark/broadcast.rb', line 4

def is_playing
  @is_playing
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/grooveshark/broadcast.rb', line 5

def name
  @name
end

#next_songObject (readonly)

Returns the value of attribute next_song.



6
7
8
# File 'lib/grooveshark/broadcast.rb', line 6

def next_song
  @next_song
end

#user_idsObject (readonly)

Returns the value of attribute user_ids.



3
4
5
# File 'lib/grooveshark/broadcast.rb', line 3

def user_ids
  @user_ids
end

#usernamesObject (readonly)

Returns the value of attribute usernames.



5
6
7
# File 'lib/grooveshark/broadcast.rb', line 5

def usernames
  @usernames
end

Instance Method Details

#reload_statusObject

Reload broadcast status Returns true on success. Otherwise false.



28
29
30
31
32
33
34
35
36
# File 'lib/grooveshark/broadcast.rb', line 28

def reload_status
  initialize(
    @client, nil,
    @client.request('broadcastStatusPoll', {:broadcastID => id})
  )
  true
rescue
  false
end