Module: CoinmarketcapFree::Icon

Defined in:
lib/coinmarketcap_free/icon.rb

Overview

Get static image of a coin from coinmarketcap.com

Class Method Summary collapse

Class Method Details

.generate_url(id_coin, size) ⇒ String

Generate URI image of a coin

 = CoinmarketcapFree::Icon.generate_url(1, 64)

Result:

"https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"

Parameters:

  • id_coin (Integer)

    Identify coin. For example, bitcoin has 1

  • size (Integer)

    Choose one size: 64, 128, 200

Returns:

  • (String)

    Return URI from coinmarketcap



17
18
19
20
21
22
23
24
25
# File 'lib/coinmarketcap_free/icon.rb', line 17

def generate_url(id_coin, size)
  size_x_size = case size
                when 64, 128, 200
                  "#{size}x#{size}"
                else
                  raise ArgumentError, "Can't find this value: #{size}"
                end
  "https://s2.coinmarketcap.com/static/img/coins/#{size_x_size}/#{id_coin}.png"
end