curtis1000
4/19/2017 - 5:12 AM

Cat Facts for Ruby/MacOS

Cat Facts for Ruby/MacOS

#!/usr/bin/env ruby
require 'rest-client'
require 'json'
require 'shellwords'

response = RestClient.get 'http://catfacts-api.appspot.com/api/facts'
raise "Problem" if response.code != 200
fact = "Did you know? " + (JSON.parse response.body)['facts'][0]
system "say #{Shellwords.escape fact}"