Created
December 23, 2018 21:29
-
-
Save monorkin/75c80479aeb834b0a5f18878766bf70f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
require 'json' | |
fetch = | |
self.method(:URI) \ | |
>> Net::HTTP.method(:get) \ | |
>> JSON.method(:parse) \ | |
>> -> response { response.dig('bpi', 'EUR', 'rate') || '0' } \ | |
>> -> value { value.gsub(',', '') } \ | |
>> self.method(:Float) | |
fetch.call('https://api.coindesk.com/v1/bpi/currentprice.json') # => 3530.6782 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment