Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Created August 27, 2013 22:31
Show Gist options
  • Save jendiamond/6359985 to your computer and use it in GitHub Desktop.
Save jendiamond/6359985 to your computer and use it in GitHub Desktop.
Exercise 12 - Learn Ruby the Hard Way
# the command require is requiring the library open-uri so we can use particular things from it
require 'open-uri'
# the method open is opening the url;
# the method "do" will enact the defined method stated after f
# to each of the lines that follow
open("http://www.ruby-lang.org/en") do |f|
f.each_line {|line| p line}
puts f.base_uri # <URI::HTTP:0x40e6ef2
puts f.content_type # "text/html"
puts f.charset # "iso-8859-1"
puts f.content_encoding # {}
puts f.last_modified # Thurs. Dec. 05 02:25 URC
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment