The Ruby function is part of the BioRuby library, which provides a wrapper around the NCBI EUtils. There was some brief discussion at the R Bioconductor mailing list regarding a wrapper for R, but I don't think that it went anywhere.
It is possible to use EUtils using RCurl and XML as you suggest. You construct the correct query URL, fetch the results using RCurl and parse using XML. I'd recommend reading the documentation in the second link for details about URLs; it is not very difficult. However, I don't think that there is a pure EUtils equivalent of BioRuby's very useful esearch_count().
EDIT: may be wrong on that last point, there is EGQuery.