Ruby bitcoind JSON RPCCall
The code is free of syntax errors, but it looks like you need to replace the rpcuser and rpcpassword in this line:

h = BitcoinRPC.new('http://rpcuser:rpcpassword@127.0.0.1:8332')

To the actual rpcuser and rpcpassword values that are set in your bitcoin.conf file. 

If that doesn't work, I'd suggest doing some debugging by opening an irb session and running this code to see the result of the HTTP request to the RPC service:

require 'net/http'
require 'json'

post_body = { method: 'getblockchaininfo', params: [], id: 'jsonrpc' }.to_json

uri = URI.parse "http://rpcuser:rpcpassword@127.0.0.1:8332"

def http_post_request(uri, post_body)
  http    = Net::HTTP.new(uri.host, uri.port)
  request = Net::HTTP::Post.new(uri.request_uri)
  request.basic_auth uri.user, uri.password
  request.content_type = 'application/json'
  request.body = post_body
  http.request(request).body
end

http_post_request(uri, post_body)