Created
September 4, 2012 18:59
-
-
Save migane/3625040 to your computer and use it in GitHub Desktop.
Reverse world in sentence with rack revisited
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_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