Skip to content

Instantly share code, notes, and snippets.

@migane
Created September 4, 2012 18:59
Show Gist options
  • Select an option

  • Save migane/3625040 to your computer and use it in GitHub Desktop.

Select an option

Save migane/3625040 to your computer and use it in GitHub Desktop.
Reverse world in sentence with rack revisited
#my_rack_mtd1.rb
# Revisited version
require 'rack'
def reverse_word_order(env)
if (ARGV.length < 1 || ARGV.length > 1 || ARGV[0].split(" ").size < 2)
[400, {}, ["Enter one sentence with at least two words to reverse the sentence"]]
else
[200, {}, [ARGV[0].split(" ").reverse.join(" ")]]
end
end
Rack::Handler::Thin.run method(:reverse_word_order)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment