Class: Voyeurb::Stream
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#actual_start_time ⇒ Object
readonly
Returns the value of attribute actual_start_time.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#scheduled_start_time ⇒ Object
readonly
Returns the value of attribute scheduled_start_time.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#viewers ⇒ Object
readonly
Returns the value of attribute viewers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Stream
constructor
A new instance of Stream.
Constructor Details
#initialize(attributes) ⇒ Stream
Returns a new instance of Stream.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/voyeurb/stream.rb', line 7 def initialize(attributes) @id = attributes["id"] @scheduled_start_time = attributes["scheduled_start_time"] @actual_start_time = attributes["actual_start_time"] @site = attributes["site"] @title = attributes["title"] @url = attributes["url"] @user = attributes["user"] @viewers = attributes["viewers"] end |
Instance Attribute Details
#actual_start_time ⇒ Object (readonly)
Returns the value of attribute actual_start_time.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def actual_start_time @actual_start_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def id @id end |
#scheduled_start_time ⇒ Object (readonly)
Returns the value of attribute scheduled_start_time.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def scheduled_start_time @scheduled_start_time end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def site @site end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def url @url end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def user @user end |
#viewers ⇒ Object (readonly)
Returns the value of attribute viewers.
4 5 6 |
# File 'lib/voyeurb/stream.rb', line 4 def viewers @viewers end |
Class Method Details
.completed ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/voyeurb/stream.rb', line 37 def self.completed # The endpoint for completed returns an error when trying to hit it the API # Will implement when is back working again. # response = Faraday.get("#{ENDPOINT}/streams/completed") # streams = JSON.parse(response.body)["data"] # streams.map { |attributes| new(attributes) } end |
.find(id) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/voyeurb/stream.rb', line 18 def self.find(id) response = Faraday.get("#{ENDPOINT}/streams/#{id}") raise StreamNotFound unless response.success? attributes = JSON.parse(response.body)["data"] new(attributes) end |
.live ⇒ Object
25 26 27 28 29 |
# File 'lib/voyeurb/stream.rb', line 25 def self.live response = Faraday.get("#{ENDPOINT}/streams/live") streams = JSON.parse(response.body)["data"] streams.map { |attributes| new(attributes) } end |
.upcoming ⇒ Object
31 32 33 34 35 |
# File 'lib/voyeurb/stream.rb', line 31 def self.upcoming response = Faraday.get("#{ENDPOINT}/streams/upcoming") streams = JSON.parse(response.body)["data"] streams.map { |attributes| new(attributes) } end |