lib/utils.rb in SimBot-0.1.23 vs lib/utils.rb in SimBot-0.1.24
- old
+ new
@@ -60,10 +60,18 @@
def self.ltcbtc_price
response = RestClient.get('https://api.coinmarketcap.com/v2/ticker/2/?convert=BTC')
hash = JSON.parse(response.body)
hash['data']['quotes']['BTC']['price'].to_f.round(4)
end
-
+ @prev_time = -1
+ @rand_val = 1
+ def self.rand_for_hour(min, max)
+ if @prev_time != Time.now.hour
+ @rand_val = rand(min...max)
+ @prev_time = Time.now.hour
+ end
+ @rand_val
+ end
# fetch btc/ltc price from coin market cap
# @return [float] rate
def self.btcltc_price
response = RestClient.get('https://api.coinmarketcap.com/v2/ticker/1/?convert=LTC')
hash = JSON.parse(response.body)