coinmarketcap_free 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d2f0b9d06cb2aa30965c8c67c23fe6694628466364a16b0cdad46ccf96dbd39
4
- data.tar.gz: caef79e1398c48c30e246ca336388ba5986f5f5ad0391f33e0825f48547f8bac
3
+ metadata.gz: 4297fadc64121db9012143a350b4030cd841416f7a7b6fdeb07b46a3234b6af9
4
+ data.tar.gz: 9860e70e322113e3cc9fbeae4af47a71c0f69032931b28705fb09448fdf42091
5
5
  SHA512:
6
- metadata.gz: 41ac065298e6cbe7daf6c57f64afb9eae284b1589447260f1a166854f5e7ce1201c2f514c9fa645c9095de3b7890223593d38c1a971a10fc601f82d2aacf6511
7
- data.tar.gz: 677eb71065cd99bc1d7cc9524e4f785684522272c98ab2c52f2de09b9e40b47e671f7af02dcee902b342a9ad77b5fb3842268476bd512a0fb44235fe2afd8539
6
+ metadata.gz: 47a049b178e777f9bf609ccd2a4015e36e4340626dc311d9850adc513e8530020c7a68a16a9d501bad48bcdf4fed516cbf4dd3f9454c000f7d0aed7aa92b811a
7
+ data.tar.gz: c54fc0e35cbbf0dc6c36f3ea8426eeaacfb11116baa46adb14b9638941d6d6f6c48eb4c395692b21371c832d6efcb7caddfc37fb9290323c8c6b0763f91f8b35
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coinmarketcap_free (0.1.1)
4
+ coinmarketcap_free (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -115,7 +115,7 @@ Result:
115
115
  If you want to sort in ascending, just write parameter:
116
116
 
117
117
  ``` Ruby
118
- list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1, sort_type:'asc')
118
+ list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1, sortType:'asc')
119
119
  ```
120
120
  or
121
121
  ``` Ruby
@@ -123,25 +123,38 @@ list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
123
123
  list.sort_type = 'asc'
124
124
  ```
125
125
 
126
- Also other parameters for Cryptocurrencies:
127
-
128
- | Name | Type | Description | Examples |
129
- |:--------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|
130
- | ```limit:``` | Integer. | Optionally specify the number of results to return. Use this parameter and the "start" parameter to determine your own pagination size. ||
131
- | ```start:``` | Integer. | Optionally offset the start (1-based index) of the paginated list of items to return. ||
132
- | ```sort_by:``` | String. | Default: ```market_cap```. (```rank```, ```name```, ```symbol```, ```date_added```, ```market_cap```, ```market_cap_strict```, ```price```, ```circulating_supply```, ```total_supply```, ```max_supply```, ```num_market_pairs```, ```volume_24h```, ```percent_change_1h```, ```percent_change_24h```, ```percent_change_7d```, ```market_cap_by_total_supply_strict```, ```volume_7d```, ```volume_30d```). What field to sort the list of cryptocurrencies by. ||
133
- | ```sort_type:``` | String. | Default: ```desc```. (```asc``` or ```desc```). The direction in which to order cryptocurrencies against the specified sort. ||
134
- | ```convert:``` | String. | Default: ```USD,BTC,ETH``` . Select cryptocurrencies to exchange (```AUD```, ```BRL```, ```CAD```, ```CHF```, ```CLP```, ```CNY```, ```CZK```, ```DKK```, ```EUR```, ```GBP```, ```HKD```, ```HUF```, ```IDR```, ```ILS```, ```INR```, ```JPY```, ```KRW```, ```MXN```, ```MYR```, ```NOK```, ```NZD```, ```PHP```, ```PKR```, ```PLN```, ```RUB```, ```SEK```, ```SGD```, ```THB```, ```TRY```, ```TWD```, ```ZAR```). | ```USD``` or ```USD,BTC,ETH``` |
135
- | ```crypto_type:``` | String. | Default: ```all```. (```all```, ```coins```, ```tokens```). The type of cryptocurrency to include. ||
136
- | ```tag_type:``` | String. | Default: ```all```. (```all```, ```defi```, ```filesharing```). The tag of cryptocurrency to include. ||
137
- | ```audited:``` | Boolean. | Show audited (true) or not (false) ||
138
- | ```aux:``` | String. | Optionally specify a comma-separated list of supplemental data fields to return. Pass ```ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap``` to include all auxiliary fields. | ```ath``` or ```ath, atl, high24h, low24h``` |
139
- | ```tags:``` | string. | If you want to see cryptocurrencies that can be mined, just type ```mineable```. ||
140
- | ```volume_24h_range:``` | String. | Optionally specify a threshold 24 hour USD volume to filter results by. | ```0~100000000000000000``` |
141
- | ```percent_change_24h_range:``` | String. | Optionally specify a threshold 24 hour percent change to filter results by. | ```0~100``` or ```-10~100``` |
142
- | ```circulating_supply_range:``` | String. | Optionally specify a threshold circulating supply to filter results by. | ```0~100000000000000000``` |
143
- | ```price_range:``` | String. | Optionally specify a threshold USD price to filter results by. | ```0~100000000000000000``` |
144
- | ```market_cap_range:``` | String. | Optionally specify a threshold market cap to filter results by. | ```0~100000000000000000``` |
126
+ You can also adding sort by:
127
+
128
+ ``` Ruby
129
+ list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'asc', sortBy: 'name')
130
+ ```
131
+
132
+ Convert cryptocurrency to:
133
+
134
+ ``` Ruby
135
+ list = CoinmarketcapFree.coins(limit: 100, start: 1, convert: 'USD,BTC,ETH')
136
+ ```
137
+
138
+
139
+ Parameters for Cryptocurrencies:
140
+
141
+ | Name | Type | Description | Examples |
142
+ |:------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|
143
+ | ```limit:``` | Integer. | Optionally specify the number of results to return. Use this parameter and the "start" parameter to determine your own pagination size. ||
144
+ | ```start:``` | Integer. | Optionally offset the start (1-based index) of the paginated list of items to return. ||
145
+ | ```sortBy:``` | String. | Default: ```market_cap```. (```rank```, ```name```, ```symbol```, ```date_added```, ```market_cap```, ```market_cap_strict```, ```price```, ```circulating_supply```, ```total_supply```, ```max_supply```, ```num_market_pairs```, ```volume_24h```, ```percent_change_1h```, ```percent_change_24h```, ```percent_change_7d```, ```market_cap_by_total_supply_strict```, ```volume_7d```, ```volume_30d```). What field to sort the list of cryptocurrencies by. ||
146
+ | ```sortType:``` | String. | Default: ```desc```. (```asc``` or ```desc```). The direction in which to order cryptocurrencies against the specified sort. ||
147
+ | ```convert:``` | String. | Default: ```USD,BTC,ETH``` . Select cryptocurrencies to exchange (```AUD```, ```BRL```, ```CAD```, ```CHF```, ```CLP```, ```CNY```, ```CZK```, ```DKK```, ```EUR```, ```GBP```, ```HKD```, ```HUF```, ```IDR```, ```ILS```, ```INR```, ```JPY```, ```KRW```, ```MXN```, ```MYR```, ```NOK```, ```NZD```, ```PHP```, ```PKR```, ```PLN```, ```RUB```, ```SEK```, ```SGD```, ```THB```, ```TRY```, ```TWD```, ```ZAR```). | ```USD``` or ```USD,BTC,ETH``` |
148
+ | ```cryptoType:``` | String. | Default: ```all```. (```all```, ```coins```, ```tokens```). The type of cryptocurrency to include. ||
149
+ | ```tagType:``` | String. | Default: ```all```. (```all```, ```defi```, ```filesharing```). The tag of cryptocurrency to include. ||
150
+ | ```audited:``` | Boolean. | Show audited (true) or not (false) ||
151
+ | ```aux:``` | String. | Optionally specify a comma-separated list of supplemental data fields to return. Pass ```ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap``` to include all auxiliary fields. | ```ath``` or ```ath, atl, high24h, low24h``` |
152
+ | ```tags:``` | string. | If you want to see cryptocurrencies that can be mined, just type ```mineable```. ||
153
+ | ```volume24hRange:``` | String. | Optionally specify a threshold 24 hour USD volume to filter results by. | ```0~100000000000000000``` |
154
+ | ```percentChange24hRange:``` | String. | Optionally specify a threshold 24 hour percent change to filter results by. | ```0~100``` or ```-10~100``` |
155
+ | ```circulatingSupplyRange:``` | String. | Optionally specify a threshold circulating supply to filter results by. | ```0~100000000000000000``` |
156
+ | ```priceRange:``` | String. | Optionally specify a threshold USD price to filter results by. | ```0~100000000000000000``` |
157
+ | ```marketCapRange:``` | String. | Optionally specify a threshold market cap to filter results by. | ```0~100000000000000000``` |
145
158
 
146
159
  ### Returns an interval of historic market quotes:
147
160
 
@@ -6,6 +6,8 @@ module CoinmarketcapFree
6
6
  class BASE
7
7
  protected
8
8
 
9
+ # @param [URI] url
10
+ # @return [String]
9
11
  def request_to_read_data(url)
10
12
  response = Net::HTTP.get_response(url, Hash('Accept': '*/*'))
11
13
 
@@ -14,6 +16,7 @@ module CoinmarketcapFree
14
16
  response.read_body
15
17
  end
16
18
 
19
+ # @return [String]
17
20
  def generate_uri_for_data
18
21
  raise NotImplementedError
19
22
  end
@@ -22,7 +25,6 @@ module CoinmarketcapFree
22
25
 
23
26
  attr_reader :get_data
24
27
 
25
- # Refresh to get data
26
28
  # @return [false, true] true data update is good If false is bad request, wrong parameter values, or the API has been updated
27
29
  def update
28
30
  begin
@@ -46,6 +46,7 @@ module CoinmarketcapFree
46
46
 
47
47
  attr_accessor :id,
48
48
  :range_time
49
+
49
50
  # Returns the CoinmarketcapFree::Coin.
50
51
  # @param id [Integer] Cryptocurrency identifier from coinmarketcap. For example, Bitcoin has the number 1
51
52
  # @param range_time [String] Range time. For example, '1D', '7D', '1M', '3M', '1Y', 'YTD', 'ALL' or custom range '1668981600~1671659999'
@@ -101,12 +101,12 @@ module CoinmarketcapFree
101
101
  #
102
102
  # If you want to sort in ascending, just write parameter:
103
103
  #
104
- # list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1, sort_type:'asc')
104
+ # list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1, sortType:'asc')
105
105
  #
106
106
  # or
107
107
  #
108
108
  # list = CoinmarketcapFree::Cryptocurrencies.new(limit: 100, start: 1)
109
- # list.sort_type = 'asc'
109
+ # list.sortType = 'asc'
110
110
  #
111
111
  # Also see other parameters.
112
112
  class Cryptocurrencies < BASE
@@ -114,65 +114,70 @@ module CoinmarketcapFree
114
114
  URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing'.freeze
115
115
  private_constant :URL_API
116
116
 
117
- # Returns the CoinmarketcapFree::Cryptocurrencies that's dictated by the options hash. The primary options are:
117
+ # Returns the CoinmarketcapFree::Cryptocurrencies that's dictated by the options hash.
118
118
  #
119
- # * <tt> start: </tt> - [Integer] Default: 1. Optionally offset the start (1-based index) of the paginated list of items to return.
120
- # * <tt> limit: </tt> - [Integer] Default: 100. Optionally specify the number of results to return.
121
- # Use this parameter and the "start" parameter to determine your own pagination size.
122
- # * <tt> sort_by: </tt> - [String] Default: "market_cap". ("rank", "name", "symbol", "date_added", "market_cap", "market_cap_strict", "price", "circulating_supply", "total_supply", "max_supply", "num_market_pairs", "volume_24h", "percent_change_1h", "percent_change_24h", "percent_change_7d", "market_cap_by_total_supply_strict", "volume_7d", "volume_30d").
123
- # What field to sort the list of cryptocurrencies by.
124
- # * <tt> sort_type: </tt> - [String] Default: "desc". ("asc" or "desc"). The direction in which to order cryptocurrencies against the specified sort.
125
- # * <tt> convert: </tt> - [String] Default: 'USD'. Default: 'USD'. Select cryptocurrencies to exchange
126
- # ("AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR").
127
- # For example, many 'USD,BTC,ETH' to convert or only one 'USD'
128
- # * <tt> crypto_typ: </tt> - [String] Default: "all". ("all", "coins", "tokens"). The type of cryptocurrency to include.
129
- # * <tt> tag_type: </tt> - [String] Default: "all". ("all", "defi", "filesharing"). The tag of cryptocurrency to include.
130
- # * <tt> audited: </tt> - [FalseClass, TrueClass] Show audited (true) or not (false)
131
- # * <tt> aux: </tt> - [String] Optionally specify a comma-separated list of supplemental data fields to return.
132
- # Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
133
- # * <tt> tags: </tt> - [String] If you want to see cryptocurrencies that can be mined, just type 'mineable'.
134
- # * <tt> volume_24h_range: </tt> - [String] Optionally specify a threshold 24 hour USD volume to filter results by.
135
- # For example, For example, '0~100000000000000000'
136
- # * <tt> percent_change_24h_range: </tt> - [String] Optionally specify a threshold 24 hour percent change to filter results by.
137
- # For example, '0~100' or '-10~100'
138
- # * <tt> circulating_supply_range: </tt> - [String] Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
139
- # * <tt> price_range: </tt> - [String] Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
140
- # * <tt> market_cap_range: </tt> - [String] Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
141
- #
142
- # @param [Hash] options
143
- def initialize(**options)
144
- @limit = options[:limit].nil? ? 100 : options[:limit] # Integer
145
- @start = options[:start].nil? ? 1 : options[:start] # Integer
146
- @sort_by = options[:sort_by] # String
147
- @sort_type = options[:sort_type] # String
148
- @convert = options[:convert] # String
149
- @crypto_type = options[:crypto_type] # String
150
- @tag_type = options[:tag_type] # String
151
- @audited = options[:audited] # Boolean
152
- @aux = options[:aux] # String
153
- @tags = options[:tags] # String
154
- @volume_24h_range = options[:volume_24h_range] # String
155
- @percent_change_24h_range = options[:percent_change_24h_range] # String
156
- @circulating_supply_range = options[:circulating_supply_range] # String
157
- @price_range = options[:price_range] # String
158
- @market_cap_range = options[:market_cap_range] # String
119
+ # @param [Integer] start Optionally offset the start (1-based index) of the paginated list of items to return.
120
+ # @param [Integer] limit Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
121
+ # @param [String (frozen)] sortBy What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
122
+ # @param [String (frozen)] sortType The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
123
+ # @param [String (frozen)] convert Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
124
+ # @param [String (frozen)] cryptoType The type of cryptocurrency to include. ('all', 'coins', 'tokens')
125
+ # @param [String (frozen)] tagType The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
126
+ # @param [TrueClass, FalseClass] audited Show audited 'true' or not 'false'
127
+ # @param [String (frozen)] aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
128
+ # @param [String (frozen)] tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
129
+ # @param [String (frozen)] volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
130
+ # @param [String (frozen)] percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
131
+ # @param [String (frozen)] circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
132
+ # @param [String (frozen)] priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
133
+ # @param [String (frozen)] marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
134
+ def initialize(start:1,
135
+ limit:100,
136
+ sortBy: 'market_cap',
137
+ sortType:'desc',
138
+ convert:'USD',
139
+ cryptoType:'all',
140
+ tagType:'all',
141
+ audited:false,
142
+ aux:nil,
143
+ tags:nil,
144
+ volume24hRange:nil,
145
+ percentChange24hRange:nil,
146
+ circulatingSupplyRange:nil,
147
+ priceRange:nil,
148
+ marketCapRange:nil)
149
+ @limit = limit # Integer
150
+ @start = start # Integer
151
+ @sortBy = sortBy # String
152
+ @sortType = sortType # String
153
+ @convert = convert # String
154
+ @cryptoType = cryptoType # String
155
+ @tagType = tagType # String
156
+ @audited = audited # Boolean
157
+ @aux = aux # String
158
+ @tags = tags # String
159
+ @volume24hRange = volume24hRange # String
160
+ @percentChange24hRange = percentChange24hRange # String
161
+ @circulatingSupplyRange = circulatingSupplyRange # String
162
+ @priceRange = priceRange # String
163
+ @marketCapRange = marketCapRange # String
159
164
  end
160
165
 
161
166
  attr_accessor :limit,
162
167
  :start,
163
- :sort_by,
164
- :sort_type,
168
+ :sortBy,
169
+ :sortType,
165
170
  :convert,
166
- :crypto_type,
167
- :tag_type,
171
+ :cryptoType,
172
+ :tagType,
168
173
  :audited,
169
174
  :aux,
170
175
  :tags,
171
- :volume_24h_range,
172
- :percent_change_24h_range,
173
- :circulating_supply_range,
174
- :price_range,
175
- :market_cap_range
176
+ :volume24hRange,
177
+ :percentChange24hRange,
178
+ :circulatingSupplyRange,
179
+ :priceRange,
180
+ :marketCapRange
176
181
 
177
182
  private
178
183
  def generate_uri_for_data
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CoinmarketcapFree
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -58,6 +58,68 @@ module CoinmarketcapFree
58
58
  @@coin.update ? @@coin.get_data : nil
59
59
  end
60
60
 
61
+ # Returns an interval of historic for the day
62
+ #
63
+ # @param [Integer] id Cryptocurrency identifier
64
+ def coin_history_day(id)
65
+ coin_history(id, '1D')
66
+ end
67
+
68
+ # Returns an interval of historic for the seven days
69
+ #
70
+ # @param [Integer] id Cryptocurrency identifier
71
+ def coin_history_seven_days(id)
72
+ coin_history(id, '7D')
73
+ end
74
+
75
+ # Returns an interval of historic for the one month
76
+ #
77
+ # @param [Integer] id Cryptocurrency identifier
78
+ def coin_history_one_month(id)
79
+ coin_history(id, '1M')
80
+ end
81
+
82
+ # Returns an interval of historic for the three months
83
+ #
84
+ # @param [Integer] id Cryptocurrency identifier
85
+ def coin_history_three_months(id)
86
+ coin_history(id, '3M')
87
+ end
88
+
89
+ # Returns an interval of historic for the one year
90
+ #
91
+ # @param [Integer] id Cryptocurrency identifier
92
+ def coin_history_one_year(id)
93
+ coin_history(id, '1Y')
94
+ end
95
+
96
+ # Returns an interval of historic for the current year
97
+ #
98
+ # @param [Integer] id Cryptocurrency identifier
99
+ def coin_history_current_year(id)
100
+ coin_history(id, 'YTD')
101
+ end
102
+
103
+ # Returns an interval of historic for the current year
104
+ #
105
+ # @param [Integer] id Cryptocurrency identifier
106
+ def coin_history_all(id)
107
+ coin_history(id, 'ALL')
108
+ end
109
+
110
+ # Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
111
+ #
112
+ # Unix Epoch. (SECONDS SINCE JAN 01 1970 (UTC))
113
+ #
114
+ # CoinmarketcapFree.coin_history_custom_time(1, 1675085165, 1675105165)
115
+ #
116
+ # @param [Integer] id Cryptocurrency identifier
117
+ # @param [Integer] from Enter a Timestamp
118
+ # @param [Integer] to Enter a Timestamp
119
+ def coin_history_custom_time(id, from, to)
120
+ coin_history(id, "#{from}~#{to}")
121
+ end
122
+
61
123
  # Get a list of cryptocurrencies
62
124
  #
63
125
  # list = CoinmarketcapFree.coins(limit: 100, start: 1)
@@ -153,56 +215,89 @@ module CoinmarketcapFree
153
215
  #
154
216
  # If you want to sort in ascending, just write parameter:
155
217
  #
156
- # list = CoinmarketcapFree.coins(limit: 100, start: 1, sort_type:'asc')
157
- #
158
- # Also see other parameters:
159
- #
160
- # * <tt> start: </tt> - [Integer] Default: 1. Optionally offset the start (1-based index) of the paginated list of items to return.
161
- # * <tt> limit: </tt> - [Integer] Default: 100. Optionally specify the number of results to return.
162
- # Use this parameter and the "start" parameter to determine your own pagination size.
163
- # * <tt> sort_by: </tt> - [String] Default: "market_cap". ("rank", "name", "symbol", "date_added", "market_cap", "market_cap_strict", "price", "circulating_supply", "total_supply", "max_supply", "num_market_pairs", "volume_24h", "percent_change_1h", "percent_change_24h", "percent_change_7d", "market_cap_by_total_supply_strict", "volume_7d", "volume_30d").
164
- # What field to sort the list of cryptocurrencies by.
165
- # * <tt> sort_type: </tt> - [String] Default: "desc". ("asc" or "desc"). The direction in which to order cryptocurrencies against the specified sort.
166
- # * <tt> convert: </tt> - [String] Default: 'USD'. Default: 'USD'. Select cryptocurrencies to exchange
167
- # ("AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR").
168
- # For example, many 'USD,BTC,ETH' to convert or only one 'USD'
169
- # * <tt> crypto_typ: </tt> - [String] Default: "all". ("all", "coins", "tokens"). The type of cryptocurrency to include.
170
- # * <tt> tag_type: </tt> - [String] Default: "all". ("all", "defi", "filesharing"). The tag of cryptocurrency to include.
171
- # * <tt> audited: </tt> - [FalseClass, TrueClass] Show audited (true) or not (false)
172
- # * <tt> aux: </tt> - [String] Optionally specify a comma-separated list of supplemental data fields to return.
173
- # Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
174
- # * <tt> tags: </tt> - [String] If you want to see cryptocurrencies that can be mined, just type 'mineable'.
175
- # * <tt> volume_24h_range: </tt> - [String] Optionally specify a threshold 24 hour USD volume to filter results by.
176
- # For example, For example, '0~100000000000000000'
177
- # * <tt> percent_change_24h_range: </tt> - [String] Optionally specify a threshold 24 hour percent change to filter results by.
178
- # For example, '0~100' or '-10~100'
179
- # * <tt> circulating_supply_range: </tt> - [String] Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
180
- # * <tt> price_range: </tt> - [String] Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
181
- # * <tt> market_cap_range: </tt> - [String] Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
182
- #
183
- # @param [Hash] options
218
+ # list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'asc')
219
+ #
220
+ # or
221
+ #
222
+ # list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'desc')
223
+ #
224
+ # You can also adding sort by:
225
+ #
226
+ # list = CoinmarketcapFree.coins(limit: 100, start: 1, sortType:'asc', sortBy: 'name')
227
+ #
228
+ # Convert cryptocurrency to::
229
+ #
230
+ # list = CoinmarketcapFree.coins(limit: 100, start: 1, convert: 'USD,BTC,ETH')
231
+ #
232
+ #
184
233
  # @return [String, nil]
185
- def coins(**options)
186
- @@cryptocurrencies.instance_variables.each do |var_name|
187
- value = options[var_name.to_s.delete('@').to_sym]
188
- @@cryptocurrencies.instance_variable_set(var_name, value) unless value.nil?
189
- end
234
+ # @param [Integer] start Optionally offset the start (1-based index) of the paginated list of items to return.
235
+ # @param [Integer] limit Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
236
+ # @param [String (frozen)] sortBy What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
237
+ # @param [String (frozen)] sortType The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
238
+ # @param [String (frozen)] convert Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
239
+ # @param [String (frozen)] cryptoType The type of cryptocurrency to include. ('all', 'coins', 'tokens')
240
+ # @param [String (frozen)] tagType The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
241
+ # @param [TrueClass, FalseClass] audited Show audited 'true' or not 'false'
242
+ # @param [String (frozen)] aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
243
+ # @param [String (frozen)] tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
244
+ # @param [String (frozen)] volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
245
+ # @param [String (frozen)] percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
246
+ # @param [String (frozen)] circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
247
+ # @param [String (frozen)] priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
248
+ # @param [String (frozen)] marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
249
+ def coins(start: 1,
250
+ limit: 100,
251
+ sortBy: 'market_cap',
252
+ sortType: 'desc',
253
+ convert: 'USD',
254
+ cryptoType: 'all',
255
+ tagType: 'all',
256
+ audited: false,
257
+ aux: nil,
258
+ tags: nil,
259
+ volume24hRange: nil,
260
+ percentChange24hRange: nil,
261
+ circulatingSupplyRange: nil,
262
+ priceRange: nil,
263
+ marketCapRange: nil)
264
+ @@cryptocurrencies.limit = limit # Integer
265
+ @@cryptocurrencies.start = start # Integer
266
+ @@cryptocurrencies.sortBy = sortBy # String
267
+ @@cryptocurrencies.sortType = sortType # String
268
+ @@cryptocurrencies.convert = convert # String
269
+ @@cryptocurrencies.cryptoType = cryptoType # String
270
+ @@cryptocurrencies.tagType = tagType # String
271
+ @@cryptocurrencies.audited = audited # Boolean
272
+ @@cryptocurrencies.aux = aux # String
273
+ @@cryptocurrencies.tags = tags # String
274
+ @@cryptocurrencies.volume24hRange = volume24hRange # String
275
+ @@cryptocurrencies.percentChange24hRange = percentChange24hRange # String
276
+ @@cryptocurrencies.circulatingSupplyRange = circulatingSupplyRange # String
277
+ @@cryptocurrencies.priceRange = priceRange # String
278
+ @@cryptocurrencies.marketCapRange = marketCapRange # String
190
279
 
191
280
  @@cryptocurrencies.update ? @@cryptocurrencies.get_data : nil
192
281
  end
193
282
 
194
283
  # Get coin logo URL from coinmarketcap
195
284
  #
196
- # logo = CoinmarketcapFree.img_coin(1, '64x64')
285
+ # logo = CoinmarketcapFree.img_coin(1, 64)
197
286
  #
198
287
  # Result:
199
288
  # "https://s2.coinmarketcap.com/static/img/coins/64x64/1.png"
200
289
  #
201
290
  # @return [String] Return URL from coinmarketcap
202
291
  # @param [Integer] id_coin Identify coin. For example, bitcoin has 1
203
- # @param [String] size Choose one size: 64x64, 128x128, 200x200
204
- def img_coin(id_coin, size)
205
- "https://s2.coinmarketcap.com/static/img/coins/#{size}/#{id_coin}.png"
292
+ # @param [Integer] size Choose one size: 64, 128, 200
293
+ def img_coin_url(id_coin, size)
294
+ size_x_size = case size
295
+ when 64, 128, 200
296
+ "#{size}x#{size}"
297
+ else
298
+ raise ArgumentError, "Can't find this value: #{size}"
299
+ end
300
+ "https://s2.coinmarketcap.com/static/img/coins/#{size_x_size}/#{id_coin}.png"
206
301
  end
207
302
  end
208
- end
303
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coinmarketcap_free
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - cosmic-1
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-23 00:00:00.000000000 Z
11
+ date: 2023-02-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Cryptocurrency information from the Coinmarketcap site without a key.
14
14
  email:
@@ -32,7 +32,7 @@ files:
32
32
  - lib/coinmarketcap_free/cryptocurrencies.rb
33
33
  - lib/coinmarketcap_free/helper.rb
34
34
  - lib/coinmarketcap_free/version.rb
35
- homepage: https://github.com/Cosmic-1/coinmarketcap_free
35
+ homepage:
36
36
  licenses:
37
37
  - MIT
38
38
  metadata: