Created
September 4, 2012 12:35
-
-
Save RajeshHuria/3620803 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
| # my_rack_mtd.rb | |
| require 'rack' | |
| def string_reverse env | |
| if ARGV[0].class == NilClass | |
| [400, {}, ["Input string missing"]] | |
| else | |
| final_str = "" | |
| str_arry = ARGV[0].to_s.reverse.split | |
| str_arry.each do |str| | |
| final_str << str.reverse | |
| final_str << " " unless str_arry.last == str | |
| end | |
| [200, {}, [final_str]] | |
| end | |
| end | |
| Rack::Handler::WEBrick.run method(:string_reverse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment