Skip to content

Instantly share code, notes, and snippets.

@RajeshHuria
Created September 3, 2012 11:56
Show Gist options
  • Select an option

  • Save RajeshHuria/3608814 to your computer and use it in GitHub Desktop.

Select an option

Save RajeshHuria/3608814 to your computer and use it in GitHub Desktop.
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({})
@RajeshHuria
Copy link
Author

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

Copy link

ghost commented Sep 3, 2012

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