Created
June 8, 2017 09:44
-
-
Save muhammadyana/ff6319b5b5a2e791e79a29e118aa00d0 to your computer and use it in GitHub Desktop.
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
# handling exception | |
#======save page into html======= | |
require 'open-uri' | |
# web_page = open("http://indoexchanger.co.id/home") | |
# output = File.open("index.html", "w") | |
# while line = web_page.gets | |
# output.puts line | |
# end | |
# output.close | |
#page =gets.chomp.to_s | |
# page ="inde" | |
# file_name = "#{page}.php" | |
# web_page = open("http://muhammadyana.web.id/#{page}") | |
# output = File.open(file_name, "w") | |
# begin | |
# while line = web_page.gets | |
# output.puts line | |
# | |
# end | |
# output.close | |
# rescue Exception | |
# STDEERR.puts "Failed to download #{page}: #{$!}" | |
# output.close | |
# File.delete(file_name) | |
# raise | |
# end | |
# begin | |
# eval string | |
# rescue SyntaxError, NameError => boom | |
# print "String doesnt compile : " + boom | |
# rescue | |
# print "Error running script : " + bang | |
# end | |
i = 10 | |
name = "Joh" | |
raise "Missing word" if name.nil? | |
if i >= name.size | |
raise IndexError, "#{i} >= size (#{name.size})" | |
end | |
raise ArgumentError, "Name too big", caller[1..-1] | |
def prompt_and_get(prompt) | |
print prompt | |
res = readline.chomp | |
throw :quit_requested if res == "!" | |
res | |
end | |
catch :quit_requested do | |
name = prompt_and_get("Name : ") | |
age = prompt_and_get("Age: ") | |
sex = prompt_and_get("Sex : ") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment