tag:blogger.com,1999:blog-27488238.post116256683508085122..comments2024-03-22T11:34:45.165+01:00Comments on taw's blog: magic/help for Rubytawhttp://www.blogger.com/profile/16972845140253292628noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-27488238.post-84464708901682585692008-02-05T01:58:00.000+01:002008-02-05T01:58:00.000+01:00Why won't this work? I am beginning. If possible, ...<B>Why won't this work? I am beginning. If possible, fixthe errors and give me a error-free one.</B><BR/>puts "What is the price for an extra large pizza?"<BR/>exprice = gets<BR/>puts "What is the price for a large pizza?"<BR/>largeprice = gets<BR/>puts "What is the price for a medium pizza?"<BR/>medprice = gets<BR/>puts "What is the price for a small pizza?"<BR/>smallprice = gets<BR/>puts "What is the price per topping?"<BR/>toppinglz = gets<BR/>puts "What is the price for a soda or drink?"<BR/>sodaprice = gets<BR/>puts "What is the name of the speciality dessert or side dish?"<BR/>side = gets.chomp<BR/>puts "What is the price of your side?" + side.to_s end<BR/>sideprice = gets<BR/>puts "Press ENTER to get the order!"<BR/>enter = gets<BR/>puts "Type of pizza."<BR/>type = gets.chomp<BR/>puts "Amount of toppings."<BR/>amount = gets.to_i<BR/>if amount = 3<BR/> puts "Topping 1."<BR/> toppingone = gets.chomp.to_s<BR/> puts "Topping 2."<BR/> toppingtwo = gets.chomp.to_s<BR/> puts "Topping 3."<BR/> toppingthree = gets.chomp.to_s<BR/> topping = 3<BR/> toppings = toppingone + " " + toppingtwo " " + toppingthree <BR/>elsif amount = 2<BR/> puts "Topping 1."<BR/> toppingone = gets.chomp.to_s<BR/> puts "Topping 2."<BR/> toppingtwo = gets.chomp.to_s<BR/> topping = 2<BR/> toppings = toppingone + " " + toppingtwo " <BR/>elsif amount = 1<BR/> puts "Topping 1."<BR/> toppingone = gets.chomp.to_s<BR/> topping = 1<BR/> toppings = toppingone <BR/>else <BR/> puts "ERROR in amount of toppings. Cannot exceed 3."<BR/>end<BR/>puts "If the size is ex-large, press 1. Large, press 2. Medium, press 3. Small, press 4."<BR/>sizef = gets<BR/>if sizef = 1<BR/> price = exprice<BR/> type = "ex-large"<BR/>elsif sizef = 2<BR/> price = largeprice<BR/> type = "large"<BR/>elsif sizef = 3<BR/> price = medprice<BR/> type = "medium"<BR/>else<BR/> price = smallprice<BR/> type "small"<BR/>end<BR/>puts "Press 5 if you want a drink. If not, press anything else."<BR/>drink = gets<BR/>if drink = 5<BR/> sodapricef = sodaprice<BR/> drinkyes = "With a Drink"<BR/>else<BR/> sodapricef = 0<BR/> drinkyes = "without a Drink"<BR/>end<BR/>puts "Do you want a " + side + "? If you do press 9. If not press anyting else."<BR/>sidel = gets<BR/>if sidel = 9<BR/> sidef = sideprice<BR/> sidel = "With a " + side <BR/>else<BR/> sidef = 0<BR/> sidel = "Without a " + side<BR/>end<BR/>puts "Your order is a:"<BR/>puts topping.chomp.to_s + " topping pizza."<BR/>puts toppings<BR/>puts type.chomp.to_s <BR/>puts drinkyes.chomp.to_s<BR/>puts sidel.chomp.to_s<BR/>puts "Total Cost:"<BR/>puts "$"sidef.to_f + sodapricef.to_f + price.to_i + topping.to_f * toppinglz.to_fAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1162748953408453162006-11-05T18:49:00.000+01:002006-11-05T18:49:00.000+01:00Logan Capaldo: magic/help is very small and very c...Logan Capaldo: magic/help is very small and very compatible. Either it or something with similar functionality should definitely be enabled by default in the standard distribution.<BR/><BR/>Before I submit a patch I'd like to check how Do-What-I-Mean it really is. The test suite covers only the simplest cases and it is very likely that magic/help doesn't handle many complex situations "right" (especially since "right" is rather subjective here).<BR/><BR/>I would be great if you (and other people who use magic/help) sent me extra test cases documenting your expectations. They are valuable no matter whether magic/help currently agrees or disagrees.<BR/><BR/>It is difficult to fairly cover all styles of Ruby programming, and I would like to avoid biasing it for my style.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1162668467107561132006-11-04T20:27:00.000+01:002006-11-04T20:27:00.000+01:00I'm pretty sure I speak for everyone when I say "T...I'm pretty sure I speak for everyone when I say "This _needs_ to be in the standard distribution" if not necessarily require'd by default.Logan Capaldohttps://www.blogger.com/profile/08200960657931329509noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1162624635440510242006-11-04T08:17:00.000+01:002006-11-04T08:17:00.000+01:00Anonymous: Thanks for reporting the problem. I cha...Anonymous: Thanks for reporting the problem. I changed it to open __FILE__ instead.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1162618195268003482006-11-04T06:29:00.000+01:002006-11-04T06:29:00.000+01:00Hi Tomasz,This is really great! Thanks!!!One litt...Hi Tomasz,<BR/><BR/>This is really great! Thanks!!!<BR/><BR/>One little thing, your tests fail on Windows because File.open("/dev/null") fails. Changing this to File.open("tc_magic_help.rb") works.<BR/><BR/>Wayne VucenicAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1162571398526150222006-11-03T17:29:00.000+01:002006-11-03T17:29:00.000+01:00Anonymous: Changing Ruby to output method document...Anonymous: Changing Ruby to output method documentation together with class documentation is trivial. In fact I tried such changes when I was coding magic/help, but eventually decided to publish the simplest code that only changes the way documentation is searched, not how it is displayed.<BR/><BR/>The obvious problem is size - Ruby descriptions are much longer, with examples and multiline descriptions, while in Python methods are usually described by a header line + 1, rarely 2 description lines. And many things are methods in Ruby and global functions in Python.<BR/><BR/>Just a quick test.<BR/><BR/>Documentation for list in Python: 123 lines.<BR/><BR/>Documentation for all instance methods of Array in Ruby: 1147 lines.<BR/>Only counting methods defined in Array class (not Object/Enumerable) - 839 lines.<BR/><BR/>It isn't really reasonable to display that much.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1162569216789568452006-11-03T16:53:00.000+01:002006-11-03T16:53:00.000+01:00Actually, I find that Ruby doesn't have much more ...Actually, I find that Ruby doesn't have much more documentation than Python (since that's one of your comparisons).<BR/><BR/>The huge difference is that RI often has <B>examples</B>, which the Python doc never has. And a little introduction to the class for classes, too.<BR/><BR/>I find Python's help to be more useful overall. One of the features I do like best in Python's help, which RI plain and simply doesn't have, is that Python's help is somewhat recursive: call `help` on any Python class and you'll get a list of all the class' methods <I>and the help blub for each of these methods</I>.<BR/><BR/>In Ruby, you only get a huge block of unreadable text dumping all of the methods, which is barely more useful than just printing `object.methods`.Anonymousnoreply@blogger.com