Class: Grooveshark::Broadcast

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

Overview

Broadcast class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Broadcast.



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

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.



8
9
10
# File 'lib/grooveshark/broadcast.rb', line 8

def active_song
  @active_song
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#is_activeObject (readonly)

Returns the value of attribute is_active.



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

def is_active
  @is_active
end

#is_playingObject (readonly)

Returns the value of attribute is_playing.



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

def is_playing
  @is_playing
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#next_songObject (readonly)

Returns the value of attribute next_song.



8
9
10
# File 'lib/grooveshark/broadcast.rb', line 8

def next_song
  @next_song
end

#user_idsObject (readonly)

Returns the value of attribute user_ids.



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

def user_ids
  @user_ids
end

#usernamesObject (readonly)

Returns the value of attribute usernames.



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

def usernames
  @usernames
end

Instance Method Details

#reload_statusObject

Reload broadcast status Returns true on success. Otherwise false.



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

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