Sha256: 3623567b603e4493b7ae1edf319f2fdea5f8790d6637fa3cd3f3ad1f10a42ebe

Contents?: true

Size: 933 Bytes

Versions: 1

Compression:

Stored size: 933 Bytes

Contents

# frozen_string_literal: true

module CoinmarketcapFree
  # Get static image of a coin from coinmarketcap.com
  module Icon
    class << self
      # Generate URI image of a coin
      #
      #   logo = CoinmarketcapFree::Icon.img_coin(1, 64)
      #
      # Result:
      #   "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
      #
      # @param [Integer] id_coin Identify coin. For example, bitcoin has 1
      # @param [Integer] size Choose one size: 64, 128, 200
      # @return [String] Return URI from coinmarketcap
      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coinmarketcap_free-0.3.0 lib/coinmarketcap_free/icon.rb