Module: Fishbans::PlayerSkins

Included in:
Fishbans
Defined in:
lib/player_skins.rb

Instance Method Summary collapse

Instance Method Details

#get_player_front(username, size = 100) ⇒ ChunkyPNG::Image

Gets the image for the entire front of the player.

Parameters:

  • username (String)

    See #get_player_head.

  • size (Integer) (defaults to: 100)

    See #get_player_head.

Returns:

  • (ChunkyPNG::Image)

    The ChunkyPNG::Image instance of that front.

Raises:

  • see #get



20
21
22
# File 'lib/player_skins.rb', line 20

def get_player_front(username, size = 100)
  get_player_image(username, 'player', size)
end

#get_player_head(username, size = 100) ⇒ ChunkyPNG::Image

Gets the image for the front face of the player head.

Parameters:

  • username (String)

    The username to get the head of.

  • size (Integer) (defaults to: 100)

    The width of the image to get.

Returns:

  • (ChunkyPNG::Image)

    The ChunkyPNG::Image instance of that head.

Raises:

  • see #get



11
12
13
# File 'lib/player_skins.rb', line 11

def get_player_head(username, size = 100)
  get_player_image(username, 'helm', size)
end

#get_player_image(username, type, size) ⇒ ChunkyPNG::Image (private)

Gets the player image for the type.

Parameters:

  • username (String)

    See #get_player_head.

  • type (String)

    The type of image to get. Can be 'helm', 'player', or 'skin' as defined by the Fishbans Player Skins API.

  • size (Integer)

    See #get_player_head.

Returns:

  • (ChunkyPNG::Image)

    The ChunkyPNG::Image instance for the params.

Raises:

  • see #get



42
43
44
45
46
# File 'lib/player_skins.rb', line 42

def get_player_image(username, type, size)
  url = "http://i.fishbans.com/#{type}/#{username}/#{size}"
  response = get(url, false)
  ChunkyPNG::Image.from_blob(response.body)
end

#get_player_skin(username, size = 64) ⇒ ChunkyPNG::Image

Gets the image for the player's raw skin.

Parameters:

  • username (String)

    See #get_player_head.

  • size (Integer) (defaults to: 64)

    See #get_player_head.

Returns:

  • (ChunkyPNG::Image)

    The ChunkyPNG::Image instance of that skin.

Raises:

  • see #get



29
30
31
# File 'lib/player_skins.rb', line 29

def get_player_skin(username, size = 64)
  get_player_image(username, 'skin', size)
end