Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- get '/anagrams/:word' do
- content_type :json
- errors = []
- if settings.lexicon.is_word?(params[:word])
- anagram_list = settings.lexicon.get_anagrams(params[:word])
- return [200, {'data': anagram_list, 'error': []}].to_json unless anagram_list.empty?
- errors.push('That word has no anagrams. Try another word?')
- return [200, {'data': [], 'error': errors}].to_json
- else
- errors.push('There is no such word in our lexicon. Try another word?')
- return [404, {'data': [], 'error': errors}].to_json
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement