diff --git a/lrthw-remnants/.gitignore b/lrthw-remnants/.gitignore new file mode 100644 index 0000000..2e1099c --- /dev/null +++ b/lrthw-remnants/.gitignore @@ -0,0 +1,3 @@ +*~ +copied.txt +.rbenv-version diff --git a/lrthw-remnants/ex1.rb b/lrthw-remnants/ex1.rb new file mode 100644 index 0000000..1fd549f --- /dev/null +++ b/lrthw-remnants/ex1.rb @@ -0,0 +1,7 @@ +puts "Hello World!" +puts "Hello Again" +puts "I like typing this." +puts "This is fun." +puts 'Yay! Printing.' +puts "I'd much rather you 'not'." +puts 'I "said" do not touch this.' diff --git a/lrthw-remnants/ex10.rb b/lrthw-remnants/ex10.rb new file mode 100644 index 0000000..4da7001 --- /dev/null +++ b/lrthw-remnants/ex10.rb @@ -0,0 +1,15 @@ +tabby_cat = "\tI'm tabbed in." +persian_cat = "I'm split\non a line." +backslash_cat = "I'm \\ a \\ cat." + +fat_cat = < + puts f.content_type # "text/html" + puts f.charset # "iso-8859-1" + puts f.content_encoding # [] + puts f.last_modified # Thu Dec 05 02:45:02 UTC 2002 +end diff --git a/lrthw-remnants/ex13.rb b/lrthw-remnants/ex13.rb new file mode 100644 index 0000000..a5e38c6 --- /dev/null +++ b/lrthw-remnants/ex13.rb @@ -0,0 +1,9 @@ +first, second, third = ARGV + +puts "The script is called: #{$0}" +puts "Your first variable is: #{first}" +puts "Your second variable is: #{second}" +puts "Your third variable is: #{third}" + +print "And your fourth is?: " +puts "That's right, it's #{STDIN.gets.chomp}" diff --git a/lrthw-remnants/ex14-ec.rb b/lrthw-remnants/ex14-ec.rb new file mode 100644 index 0000000..689222e --- /dev/null +++ b/lrthw-remnants/ex14-ec.rb @@ -0,0 +1,28 @@ +user = ARGV.first +prompt = '~: ' + +puts "Hi #{user}, I'm the #{$0} script." +puts "I'd like to ask you a few questions." +puts "Do you like me #{user}?" +print prompt +likes = STDIN.gets.chomp + +puts "Where do you live #{user}?" +print prompt +lives = STDIN.gets.chomp + +puts "What kind of computer do you have?" +print prompt +computer = STDIN.gets.chomp + +puts "What's your favorite name for a dog?" +print prompt +dogname = STDIN.gets.chomp + +puts < -2 +puts "Is it greater or equal?", 5 >= -2 +puts "Is it less or equal?", 5 <= -2 diff --git a/lrthw-remnants/ex4.rb b/lrthw-remnants/ex4.rb new file mode 100644 index 0000000..1712506 --- /dev/null +++ b/lrthw-remnants/ex4.rb @@ -0,0 +1,15 @@ +cars = 100 +space_in_a_car = 4.0 +drivers = 30 +passengers = 90 +cars_not_driven = cars - drivers +cars_driven = drivers +carpool_capacity = cars_driven * space_in_a_car +average_passengers_per_car = passengers / cars_driven + +puts "There are #{cars} cars available." +puts "There are only #{drivers} drivers available." +puts "There will be #{cars_not_driven} empty cars today." +puts "We can transport #{carpool_capacity} people today." +puts "We have #{passengers} passengers to carpool today." +puts "We need to put about #{average_passengers_per_car} in each car." diff --git a/lrthw-remnants/ex5.rb b/lrthw-remnants/ex5.rb new file mode 100644 index 0000000..5998ab2 --- /dev/null +++ b/lrthw-remnants/ex5.rb @@ -0,0 +1,18 @@ +my_name = 'Zed A. Shaw' +my_age = 35 +my_height = 74 +my_weight = 180 +my_eyes = 'Blue' +my_teeth = 'White' +my_hair = 'Brown' + +puts "Let's talk about %s." % my_name +puts "He's %d inches tall." % my_height +puts "He's %d pounds heavy." % my_weight +puts "Actually that's not too heavy." +puts "He's got %s eyes and %s hair." % [my_eyes, my_hair] +puts "His teeth are usually %s depending on the coffee." % my_teeth + +# this line is tricky, try to get it exactly right +puts "If I add %d, %d, and %d I get %d." % [ + my_age, my_height, my_weight, my_age + my_height + my_weight] diff --git a/lrthw-remnants/ex6.rb b/lrthw-remnants/ex6.rb new file mode 100644 index 0000000..b6361f5 --- /dev/null +++ b/lrthw-remnants/ex6.rb @@ -0,0 +1,20 @@ +x = "There are #{10} types of people." +binary = "binary" +do_not = "don't" +y = "Those who know #{binary} and those who #{do_not}." + +puts x +puts y + +puts "I said: #{x}" +puts "I also said: '#{y}'." + +hilarious = false +joke_evaluation = "Isn't that joke so funny?! #{hilarious}" + +puts joke_evaluation + +w = "This is the left side of..." +e = "a string with a right side." + +puts w + e diff --git a/lrthw-remnants/ex7.rb b/lrthw-remnants/ex7.rb new file mode 100644 index 0000000..e163cfa --- /dev/null +++ b/lrthw-remnants/ex7.rb @@ -0,0 +1,25 @@ +puts "Mary had a little lamb." +puts "Its fleece was white as %s." % 'snow' +puts "And everywhere that Mary went." +puts "." * 10 # what'd that do? + +end1 = "C" +end2 = "h" +end3 = "e" +end4 = "e" +end5 = "s" +end6 = "e" +end7 = "B" +end8 = "u" +end9 = "r" +end10 = "g" +end11 = "e" +end12 = "r" + +# notice how we are using print instead of puts here. change it to puts +# and see what happens. +print end1 + end2 + end3 + end4 + end5 + end6 +print end7 + end8 + end9 + end10 + end11 + end12 + +# this just is polite use of the terminal, try removing it +puts diff --git a/lrthw-remnants/ex8.rb b/lrthw-remnants/ex8.rb new file mode 100644 index 0000000..a75b3db --- /dev/null +++ b/lrthw-remnants/ex8.rb @@ -0,0 +1,12 @@ +formatter = "%s %s %s %s" + +puts formatter % [1, 2, 3, 4] +puts formatter % ["one", "two", "three", "four"] +puts formatter % [true, false, false, true] +puts formatter % [formatter, formatter, formatter, formatter] +puts formatter % [ + "I had this thing.", + "That you could type up right.", + "But it didn't sing.", + "So I said goodnight." +] diff --git a/lrthw-remnants/ex9.rb b/lrthw-remnants/ex9.rb new file mode 100644 index 0000000..5bd8195 --- /dev/null +++ b/lrthw-remnants/ex9.rb @@ -0,0 +1,14 @@ +# Here's some new strange stuff, remember type it exactly. + +days = "Mon Tue Wed Thu Fri Sat Sun" +months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" + +puts "Here are the days: ", days +puts "Here are the months: ", months + +puts <