Class: Voyeurb::Streamer
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#twitch ⇒ Object
readonly
Returns the value of attribute twitch.
-
#youtube ⇒ Object
readonly
Returns the value of attribute youtube.
Class Method Summary collapse
Instance Method Summary collapse
- #completed ⇒ Object
-
#initialize(attributes) ⇒ Streamer
constructor
A new instance of Streamer.
- #live ⇒ Object
- #upcoming ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Streamer
Returns a new instance of Streamer.
5 6 7 8 9 |
# File 'lib/voyeurb/streamer.rb', line 5 def initialize(attributes) @name = attributes["name"] @twitch = attributes["twitch"] @youtube = attributes["youtube"] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/voyeurb/streamer.rb', line 3 def name @name end |
#twitch ⇒ Object (readonly)
Returns the value of attribute twitch.
3 4 5 |
# File 'lib/voyeurb/streamer.rb', line 3 def twitch @twitch end |
#youtube ⇒ Object (readonly)
Returns the value of attribute youtube.
3 4 5 |
# File 'lib/voyeurb/streamer.rb', line 3 def youtube @youtube end |
Class Method Details
.all ⇒ Object
18 19 20 21 22 |
# File 'lib/voyeurb/streamer.rb', line 18 def self.all response = Faraday.get("#{ENDPOINT}/streamers") streamers = JSON.parse(response.body)["data"] streamers.map { |attributes| new(attributes) } end |
.by_name(name) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/voyeurb/streamer.rb', line 11 def self.by_name(name) response = Faraday.get("#{ENDPOINT}/streamers/#{name}") raise StreamerNotFound unless response.success? attributes = JSON.parse(response.body)["data"] new(attributes) end |
Instance Method Details
#completed ⇒ Object
36 37 38 39 40 |
# File 'lib/voyeurb/streamer.rb', line 36 def completed response = Faraday.get("#{ENDPOINT}/streamers/#{name}/completed") streams = JSON.parse(response.body)["data"] streams.map { |attributes| Stream.new(attributes) } end |