Created
August 27, 2013 22:31
-
-
Save jendiamond/6359985 to your computer and use it in GitHub Desktop.
Exercise 12 - Learn Ruby the Hard Way
This file contains hidden or 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
# 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