Class: CoinTools::BitBay
- Inherits:
-
Object
- Object
- CoinTools::BitBay
- Defined in:
- lib/cointools/bitbay.rb
Defined Under Namespace
Classes: BadRequestException, DataPoint, ErrorResponseException, InvalidResponseException
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#get_price(market) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cointools/bitbay.rb', line 29 def get_price(market) url = URI("#{BASE_URL}/#{market}/ticker.json") response = make_request(url) case response when Net::HTTPSuccess json = JSON.load(response.body) if json['code'] raise ErrorResponseException.new("#{json['code']} #{json['message']}") end price = json['last'] return DataPoint.new(price, nil) when Net::HTTPBadRequest raise BadRequestException.new(response) else raise InvalidResponseException.new(response) end end |