Class: Cathodic::TwitchData
- Inherits:
-
Object
- Object
- Cathodic::TwitchData
- Defined in:
- lib/cathodic.rb
Instance Attribute Summary collapse
-
#account_name ⇒ Object
Returns the value of attribute account_name.
-
#banner ⇒ Object
Returns the value of attribute banner.
-
#chat ⇒ Object
Returns the value of attribute chat.
-
#embed ⇒ Object
Returns the value of attribute embed.
-
#embed_height ⇒ Object
Returns the value of attribute embed_height.
-
#embed_width ⇒ Object
Returns the value of attribute embed_width.
-
#entry_point ⇒ Object
Returns the value of attribute entry_point.
-
#game ⇒ Object
Returns the value of attribute game.
-
#logo ⇒ Object
Returns the value of attribute logo.
-
#online ⇒ Object
Returns the value of attribute online.
-
#status ⇒ Object
Returns the value of attribute status.
-
#stream_name ⇒ Object
Returns the value of attribute stream_name.
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
-
#url ⇒ Object
Returns the value of attribute url.
-
#viewers ⇒ Object
Returns the value of attribute viewers.
Instance Method Summary collapse
-
#initialize(url, embed_width = 640, embed_height = 360) ⇒ TwitchData
constructor
A new instance of TwitchData.
- #refresh_data ⇒ Object
Constructor Details
#initialize(url, embed_width = 640, embed_height = 360) ⇒ TwitchData
Returns a new instance of TwitchData.
17 18 19 20 21 22 23 24 25 |
# File 'lib/cathodic.rb', line 17 def initialize(url, = 640, = 360) @entry_point = "https://api.twitch.tv/kraken" @url = url extract_account @query_point = @entry_point + "/streams/" + @account_name @embed_width = @embed_height = extract_data end |
Instance Attribute Details
#account_name ⇒ Object
Returns the value of attribute account_name.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def account_name @account_name end |
#banner ⇒ Object
Returns the value of attribute banner.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def @banner end |
#chat ⇒ Object
Returns the value of attribute chat.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def chat @chat end |
#embed ⇒ Object
Returns the value of attribute embed.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def @embed end |
#embed_height ⇒ Object
Returns the value of attribute embed_height.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def @embed_height end |
#embed_width ⇒ Object
Returns the value of attribute embed_width.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def @embed_width end |
#entry_point ⇒ Object
Returns the value of attribute entry_point.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def entry_point @entry_point end |
#game ⇒ Object
Returns the value of attribute game.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def game @game end |
#logo ⇒ Object
Returns the value of attribute logo.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def logo @logo end |
#online ⇒ Object
Returns the value of attribute online.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def online @online end |
#status ⇒ Object
Returns the value of attribute status.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def status @status end |
#stream_name ⇒ Object
Returns the value of attribute stream_name.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def stream_name @stream_name end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def thumbnail @thumbnail end |
#url ⇒ Object
Returns the value of attribute url.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def url @url end |
#viewers ⇒ Object
Returns the value of attribute viewers.
15 16 17 |
# File 'lib/cathodic.rb', line 15 def viewers @viewers end |
Instance Method Details
#refresh_data ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cathodic.rb', line 27 def refresh_data answer_string = open(@query_point).read parsed_answer = JSON.parse(answer_string) if parsed_answer["stream"] == nil @online = false else @online = true stream = parsed_answer.fetch("stream") channel = stream.fetch("channel") @game = stream["game"] @viewers = stream["viewers"] @status = channel["status"] end end |