Class: Twitch::V2::Images

Inherits:
Object
  • Object
show all
Defined in:
lib/kappa/images.rb

Overview

A group of URLs pointing to variously-sized versions of the same image.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#large_urlString (readonly)

Returns URL for the large-sized version of this image.

Examples:

"http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-240x144.jpg"

Returns:

  • (String)

    URL for the large-sized version of this image.



25
26
27
# File 'lib/kappa/images.rb', line 25

def large_url
  @large_url
end

#medium_urlString (readonly)

Returns URL for the medium-sized version of this image.

Examples:

"http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-120x72.jpg"

Returns:

  • (String)

    URL for the medium-sized version of this image.



30
31
32
# File 'lib/kappa/images.rb', line 30

def medium_url
  @medium_url
end

#small_urlString (readonly)

Returns URL for the small-sized version of this image.

Examples:

"http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-60x36.jpg"

Returns:

  • (String)

    URL for the small-sized version of this image.



35
36
37
# File 'lib/kappa/images.rb', line 35

def small_url
  @small_url
end

#template_urlString (readonly)

Note:

You shouldn't need to use this property directly. See #url for getting a formatted URL instead.

Returns Template image URL with placeholders for width and height.

Examples:

"http://static-cdn.jtvnw.net/ttv-logoart/League%20of%20Legends-{width}x{height}.jpg"

Returns:

  • (String)

    Template image URL with placeholders for width and height.

See Also:



42
43
44
# File 'lib/kappa/images.rb', line 42

def template_url
  @template_url
end

Instance Method Details

#url(width, height) ⇒ String

Get a URL pointing to an image with a specific size.

Examples:

url = images.url(320, 200)

Parameters:

  • width (Fixnum)

    Desired width of the image.

  • height (Fixnum)

    Desired height of the image.

Returns:

  • (String)

    URL pointing to the image with the specified size.



18
19
20
# File 'lib/kappa/images.rb', line 18

def url(width, height)
  @template_url.gsub('{width}', width.to_s).gsub('{height}', height.to_s)
end