-
-
Save cayblood/1779082 to your computer and use it in GitHub Desktop.
Vital Ruby Advanced Lab 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
class UrlFetcher | |
def self.fetch(url) | |
returnval = nil | |
begin | |
open(url) {|stream| returnval = stream.read} | |
rescue | |
end | |
returnval | |
end | |
end | |
if __FILE__ == $0 | |
body = UrlFetcher.fetch(ARGV.first) | |
if body | |
puts body | |
else | |
puts "Error opening #{ARGV.first}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment