Sha256: f537566037e71269115899db41a84835c85e79194cc6bf64dc5ccbed9130c2d5

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

module CoinmarketcapFree
  class Coin
    # Create all methods for each time interval
    CoinHistory::INTERVAL_TIME.each do |key, value|
      class_eval("def #{key}; histories('#{value}'); end", __FILE__, __LINE__)
    end

    # Get the full history of cryptocurrencies and their prices.
    #
    #     coin = CoinmarketcapFree::Coin.list.first
    #     histories = coin.histories('1D')
    #
    # or
    #
    #     histories = coin.one_day
    #     histories = coin.seven_days
    #     histories = coin.one_month
    #     histories = coin.three_months
    #     histories = coin.one_year
    #     histories = coin.current_year
    #     histories = coin.all
    #
    # @param interval [String] Select time interval. ('1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom '1668981600~1671659999')
    # @return [Array<CoinmarketcapFree::CoinHistory>] Return CoinHistory object
    def histories(interval)
      CoinHistory.custom_time(@id, interval)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coinmarketcap_free-1.0.1 lib/coinmarketcap_free/coin/histories.rb