# HEY HACKER! THIS IS AN AUTO-GENERATED FILE. # So don't bother editing it. To see how it's built, take a look at the Rakefile module WordMethods # Given a word as a string, returns the WordObject that represents it # def get_word(word, *args) http_method = :get path = '/word/{word}' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns examples for a word # def get_examples(word, *args) http_method = :get path = '/word/{word}/examples' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Return definitions for a word # def get_definitions(word, *args) http_method = :get path = '/word/{word}/definitions' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns word usage over time # def get_word_frequency(word, *args) http_method = :get path = '/word/{word}/frequency' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns a top example for a word # def get_top_example(word, *args) http_method = :get path = '/word/{word}/topExample' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Return related words (thesaurus data) for a word # def get_related_words(word, *args) http_method = :get path = '/word/{word}/related' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Fetches bi-gram phrases for a word # def get_phrases(word, *args) http_method = :get path = '/word/{word}/phrases' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns syllable information for a word # def get_hyphenation(word, *args) http_method = :get path = '/word/{word}/hyphenation' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns text pronunciations for a given word # def get_text_pronunciations(word, *args) http_method = :get path = '/word/{word}/pronunciations' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns other forms of a word # def get_word_forms(word, *args) http_method = :get path = '/word/{word}/wordForms' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Fetches audio metadata for a word. # The metadata includes a time-expiring fileUrl which allows reading the audio file directly from the API. Currently only audio pronunciations from the American Heritage Dictionary in mp3 format are supported. # def get_audio(word, *args) http_method = :get path = '/word/{word}/audio' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns definitions for a word based on the sentence in which it is found # Use the offset parameter when the word occurs more than once in the sentence # def contextual_lookup(word, *args) http_method = :get path = '/word/{word}/contextualLookup' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end # Returns definitions for a word based on the sentence in which it is found # Use the offset parameter when the word occurs more than once in the sentence # def contextual_lookup_post(word, *args) http_method = :post path = '/word/{word}/contextualLookup' path.sub!('{word}', word) # Ruby turns all key-value arguments at the end into a single hash # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb') # becomes {:limit => 10, :part_of_speech => 'verb'} last_arg = args.pop if args.last.is_a?(Hash) last_arg = args.pop if args.last.is_a?(Array) last_arg ||= {} # Look for a kwarg called :request_only, whose presence indicates # that we want the request itself back, not the response body if last_arg.is_a?(Hash) && last_arg[:request_only].present? request_only = true last_arg.delete(:request_only) end if [:post, :put].include?(http_method) params = nil body = last_arg else params = last_arg body = nil end request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end end