Class: ZendeskAPI::Playlist
- Inherits:
-
Object
- Object
- ZendeskAPI::Playlist
- Includes:
- Rescue
- Defined in:
- lib/zendesk_api/resources/playlist.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#ticket ⇒ Object
readonly
Returns the value of attribute ticket.
Instance Method Summary collapse
- #destroy ⇒ Object
- #destroyed? ⇒ Boolean
- #each ⇒ Object
-
#initialize(client, id) ⇒ Playlist
constructor
A new instance of Playlist.
- #initialized? ⇒ Boolean
- #next ⇒ Object
Constructor Details
#initialize(client, id) ⇒ Playlist
Returns a new instance of Playlist.
8 9 10 11 12 13 14 15 16 |
# File 'lib/zendesk_api/resources/playlist.rb', line 8 def initialize(client, id) @client, @id = client, id @ticket = nil @initialized = false @destroyed = false init_playlist end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/zendesk_api/resources/playlist.rb', line 6 def id @id end |
#ticket ⇒ Object (readonly)
Returns the value of attribute ticket.
5 6 7 |
# File 'lib/zendesk_api/resources/playlist.rb', line 5 def ticket @ticket end |
Instance Method Details
#destroy ⇒ Object
41 42 43 44 |
# File 'lib/zendesk_api/resources/playlist.rb', line 41 def destroy response = @client.connection.delete("play") @destroyed = response.status == 204 end |
#destroyed? ⇒ Boolean
46 47 48 |
# File 'lib/zendesk_api/resources/playlist.rb', line 46 def destroyed? @destroyed end |
#each ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/zendesk_api/resources/playlist.rb', line 18 def each init_playlist unless initialized? while initialized? && !destroyed? && (n = self.next) yield n end end |
#initialized? ⇒ Boolean
50 51 52 |
# File 'lib/zendesk_api/resources/playlist.rb', line 50 def initialized? @initialized end |
#next ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/zendesk_api/resources/playlist.rb', line 26 def next init_playlist unless initialized? return false if !initialized? || destroyed? response = @client.connection.get("play/next") if response.status == 200 @ticket = Ticket.new(@client, response.body["ticket"]) @ticket else @destroyed = (response.status == 204) nil end end |