Do you know about open-uri ?
require 'open-uri' open("/home/me/file.txt") { |f| ... } open("http://www.google.com") { |f| ... }
Therefore, to support "http: //" or "file: //" in one of the statements, simply delete "file: //" from the beginning of the uri, if it is present (and there is no need to do any processing for "http: //") , eg:
uri = ... open(uri.sub(%r{^file://}, ''))
source share