Class: Cathodic::Thumbnail
- Inherits:
-
Object
- Object
- Cathodic::Thumbnail
- Defined in:
- lib/cathodic/thumbnail.rb
Overview
The Thumbnail class represents a twitch thumbnail, you can access any type of thumbnail representing a small preview of the stream any time Author::Paul Forti License::MIT -small : the url to a small thumbnail 80x50 -medium : the url to a medium thumbnail 320x200 -large : the url to a large thumbnail 640x400 -template : the url to a generic thumbnail, you have to replace width by the width you want, same goes for height -sized_thumb : nil if sized has not been called, otherwise it’s the url to a custom sized thumbnail (the size is defined when calling sized)
Instance Attribute Summary collapse
-
#large ⇒ Object
Returns the value of attribute large.
-
#medium ⇒ Object
Returns the value of attribute medium.
-
#sized_thumb ⇒ Object
Returns the value of attribute sized_thumb.
-
#small ⇒ Object
Returns the value of attribute small.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(stream_hash) ⇒ Thumbnail
constructor
The constructor needs a hash representing the stream object Must be fetched from the Twitch.tv API (or have the same structure) -stream_hash : the hash representing the twitch.tv stream.
-
#sized(width, height) ⇒ Object
Sized generates the url of a stream thumbnail that is width large and height tall width : The thumbnail’s desired width height : The thumbnail’s desired height.
Constructor Details
#initialize(stream_hash) ⇒ Thumbnail
The constructor needs a hash representing the stream object Must be fetched from the Twitch.tv API (or have the same structure) -stream_hash : the hash representing the twitch.tv stream.
16 17 18 19 20 |
# File 'lib/cathodic/thumbnail.rb', line 16 def initialize(stream_hash) raise "Uncorrect stream hash" if !stream_hash.has_key?("preview") @preview = stream_hash.fetch("preview") extract_thumbnails end |
Instance Attribute Details
#large ⇒ Object
Returns the value of attribute large.
11 12 13 |
# File 'lib/cathodic/thumbnail.rb', line 11 def large @large end |
#medium ⇒ Object
Returns the value of attribute medium.
11 12 13 |
# File 'lib/cathodic/thumbnail.rb', line 11 def medium @medium end |
#sized_thumb ⇒ Object
Returns the value of attribute sized_thumb.
11 12 13 |
# File 'lib/cathodic/thumbnail.rb', line 11 def sized_thumb @sized_thumb end |
#small ⇒ Object
Returns the value of attribute small.
11 12 13 |
# File 'lib/cathodic/thumbnail.rb', line 11 def small @small end |
#template ⇒ Object
Returns the value of attribute template.
11 12 13 |
# File 'lib/cathodic/thumbnail.rb', line 11 def template @template end |
Instance Method Details
#sized(width, height) ⇒ Object
Sized generates the url of a stream thumbnail that is width large and height tall width : The thumbnail’s desired width height : The thumbnail’s desired height
25 26 27 28 29 |
# File 'lib/cathodic/thumbnail.rb', line 25 def sized(width, height) @sized_thumb = @template @sized_thumb.sub! "{width}", width.to_s @sized_thumb.sub! "{height}", height.to_s end |