Skip to content

Instantly share code, notes, and snippets.

@monorkin
Created December 23, 2018 21:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monorkin/75c80479aeb834b0a5f18878766bf70f to your computer and use it in GitHub Desktop.
Save monorkin/75c80479aeb834b0a5f18878766bf70f to your computer and use it in GitHub Desktop.
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