Skip to content

Instantly share code, notes, and snippets.

@RajeshHuria
Created September 4, 2012 12:35
Show Gist options
  • Select an option

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

Select an option

Save RajeshHuria/3620803 to your computer and use it in GitHub Desktop.
# 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