lib/wordnik/resource_modules/word.rb in wordnik-4.06.08 vs lib/wordnik/resource_modules/word.rb in wordnik-4.06.10

- old
+ new

@@ -382,15 +382,15 @@ body ||= {} request = Wordnik::Request.new(http_method, path, :params => params, :body => body) request_only ? request : request.response.body end - # Returns citations for a word + # Given a word as a string, returns relationships from the Word Graph # - def get_citations(word, *args) + def get_related_words(word, *args) http_method = :get - path = '/word/{word}/citations' + path = '/word/{word}/relatedWords' path.sub!('{word}', word.to_s) # 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'} @@ -603,9 +603,36 @@ # Returns the Scrabble score for a word # def get_scrabble_score(word, *args) http_method = :get path = '/word/{word}/scrabbleScore' + path.sub!('{word}', word.to_s) + + # 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 + + params = last_arg + body ||= {} + request = Wordnik::Request.new(http_method, path, :params => params, :body => body) + request_only ? request : request.response.body + end + + # Returns citations for a word + # + def get_citations(word, *args) + http_method = :get + path = '/word/{word}/citations' path.sub!('{word}', word.to_s) # 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'} \ No newline at end of file