-
-
Save RajeshHuria/3608814 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
| def display(number) | |
| print "The number you entered on the command line is " | |
| if number < 0 | |
| puts "negative" | |
| elsif number > 0 | |
| puts "positive" | |
| else | |
| puts "zero" | |
| end | |
| end | |
| my_rack_proc = lambda { |env| [200, {"Content-Type" => "text/plain"},display(ARGV[0].to_i)] } | |
| puts my_rack_proc.call({}) |
Author
Congrats. You were the first to post the Gist URL. You can improve upon the display method. Ideally,. I will not use puts inside the method. I am sure you can modify the same.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Write a Rack program that accepts an integer number from the command line. The Rack program has a method which looks at the number and then returns a string “positive”, “negative” or “zero”. The Rack program uses this method to display, for example:
200
{"Content-Type"=>"text/plain"}
The number you entered on the command line is zero