Module: WordMethods
- Defined in:
- lib/wordnik/resource_modules/word.rb
Overview
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
Instance Method Summary collapse
-
#add_audio(word, body, *args) ⇒ Object
Creates AudioPron metadata.
-
#add_tag_to_word(word, *args) ⇒ Object
Adds a tag to a word.
-
#add_word_to_favorites(word, *args) ⇒ Object
Favorites a Word for a user.
-
#add_word_view(word, *args) ⇒ Object
Records a word view from the website.
-
#comment_on_word(word, body, *args) ⇒ Object
Adds a comment to a word.
-
#delete_audio(word, audio_id, *args) ⇒ Object
Deletes an AudioPron.
-
#delete_comment_by_id_on_word(word, commentId, *args) ⇒ Object
Deletes an existing word comment.
-
#delete_from_favorites(word, *args) ⇒ Object
Removes a Word from a user’s Favorites.
-
#delete_tag_from_word(word, *args) ⇒ Object
Removes a tag from a word.
-
#get_audio(word, *args) ⇒ Object
Fetches audio metadata for a word.
-
#get_bigrams_internal(word, *args) ⇒ Object
Returns Bigrams for the given word.
-
#get_citations(word, *args) ⇒ Object
Returns citations for a word.
-
#get_comment_count(word, *args) ⇒ Object
Returns the number of comments on a word.
-
#get_comment_on_word(word, commentId, *args) ⇒ Object
Fetches a Comment by ID.
-
#get_comments_on_word(word, *args) ⇒ Object
Fetches comments on a Word.
-
#get_definitions(word, *args) ⇒ Object
Return definitions for a word.
-
#get_entries(word, *args) ⇒ Object
Return entries for a word.
-
#get_etymologies(word, *args) ⇒ Object
Fetches etymology data.
-
#get_examples(word, *args) ⇒ Object
Returns examples for a word.
-
#get_examples_post(word, body, *args) ⇒ Object
Fetches examples for a word.
-
#get_favorite_count(word, *args) ⇒ Object
Returns the number of times a word has been Favorited.
-
#get_first_listed_by(word, *args) ⇒ Object
Returns the first User to list a particular word.
-
#get_first_listed_in(word, *args) ⇒ Object
Returns the first WordList a word appeared in.
-
#get_first_usage_of_word(word, *args) ⇒ Object
Returns first usage of a word.
-
#get_flickr_images(word, *args) ⇒ Object
Returns Flickr images for a word.
-
#get_hyphenation(word, *args) ⇒ Object
Returns syllable information for a word.
-
#get_listed_in(word, *args) ⇒ Object
Returns WordLists containing a word.
-
#get_listed_in_count(word, *args) ⇒ Object
Returns a count of lists a word appears in.
-
#get_lookup_count(word, *args) ⇒ Object
Returns the number of times a word has been viewed.
-
#get_phrases(word, *args) ⇒ Object
Fetches bi-gram phrases for a word.
-
#get_pronunciation(word, pronId, *args) ⇒ Object
Fetches single audio pronunciation.
-
#get_related(word, *args) ⇒ Object
Return related words (thesaurus data) for a word.
-
#get_related_words(word, *args) ⇒ Object
Given a word as a string, returns relationships from the Word Graph.
-
#get_scrabble_score(word, *args) ⇒ Object
Returns the Scrabble score for a word.
-
#get_tag_count_on_word(word, *args) ⇒ Object
Fetches tag count for a word.
-
#get_tags_on_word(word, *args) ⇒ Object
Fetches tags for a word.
-
#get_text_pronunciations(word, *args) ⇒ Object
Returns text pronunciations for a given word.
-
#get_top_example(word, *args) ⇒ Object
Returns a top example for a word.
-
#get_unigram_count_internal(word, *args) ⇒ Object
Returns syllable information for a word.
-
#get_word(word, *args) ⇒ Object
Given a word as a string, returns the WordObject that represents it.
-
#get_word_forms(word, *args) ⇒ Object
Returns other forms of a word.
-
#get_word_frequency(word, *args) ⇒ Object
Returns word usage over time.
-
#get_word_stats(word, *args) ⇒ Object
Returns word statistics.
-
#is_favorite(word, *args) ⇒ Object
Checks to see if a word is a user’s favorite.
-
#update_audio_internal(word, body, *args) ⇒ Object
Internal method to update an audio object.
-
#update_comment_on_word(word, body, *args) ⇒ Object
Updates an existing word comment.
Instance Method Details
#add_audio(word, body, *args) ⇒ Object
Creates AudioPron metadata
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 |
# File 'lib/wordnik/resource_modules/word.rb', line 1145 def add_audio(word, body, *args) http_method = :post path = '/word/{word}/audio' 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 |
#add_tag_to_word(word, *args) ⇒ Object
Adds a tag to a word
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
# File 'lib/wordnik/resource_modules/word.rb', line 656 def add_tag_to_word(word, *args) http_method = :post path = '/word/{word}/tag' 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 |
#add_word_to_favorites(word, *args) ⇒ Object
Favorites a Word for a user
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 |
# File 'lib/wordnik/resource_modules/word.rb', line 845 def add_word_to_favorites(word, *args) http_method = :post path = '/word/{word}/favorite' 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 |
#add_word_view(word, *args) ⇒ Object
Records a word view from the website
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 |
# File 'lib/wordnik/resource_modules/word.rb', line 764 def add_word_view(word, *args) http_method = :post path = '/word/{word}/wordView' 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 |
#comment_on_word(word, body, *args) ⇒ Object
Adds a comment to a word
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 |
# File 'lib/wordnik/resource_modules/word.rb', line 1063 def comment_on_word(word, body, *args) http_method = :post path = '/word/{word}/comment' 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 |
#delete_audio(word, audio_id, *args) ⇒ Object
Deletes an AudioPron
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 |
# File 'lib/wordnik/resource_modules/word.rb', line 1228 def delete_audio(word, audio_id, *args) http_method = :delete path = '/word/{word}/audio/{audio_id}' path.sub!('{word}', word.to_s) path.sub!('{audio_id}', audio_id.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 |
#delete_comment_by_id_on_word(word, commentId, *args) ⇒ Object
Deletes an existing word comment
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
# File 'lib/wordnik/resource_modules/word.rb', line 1035 def delete_comment_by_id_on_word(word, commentId, *args) http_method = :delete path = '/word/{word}/comment/{commentId}' path.sub!('{word}', word.to_s) path.sub!('{commentId}', commentId.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 |
#delete_from_favorites(word, *args) ⇒ Object
Removes a Word from a user’s Favorites
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
# File 'lib/wordnik/resource_modules/word.rb', line 872 def delete_from_favorites(word, *args) http_method = :delete path = '/word/{word}/favorite' 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 |
#delete_tag_from_word(word, *args) ⇒ Object
Removes a tag from a word
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
# File 'lib/wordnik/resource_modules/word.rb', line 683 def delete_tag_from_word(word, *args) http_method = :delete path = '/word/{word}/tag' 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 |
#get_audio(word, *args) ⇒ Object
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.
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 |
# File 'lib/wordnik/resource_modules/word.rb', line 1118 def get_audio(word, *args) http_method = :get path = '/word/{word}/audio' 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 |
#get_bigrams_internal(word, *args) ⇒ Object
Returns Bigrams for the given word
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
# File 'lib/wordnik/resource_modules/word.rb', line 575 def get_bigrams_internal(word, *args) http_method = :get path = '/word/{word}/phrasesInternal' 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 |
#get_citations(word, *args) ⇒ Object
Returns citations for a word
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
# File 'lib/wordnik/resource_modules/word.rb', line 494 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'} 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 |
#get_comment_count(word, *args) ⇒ Object
Returns the number of comments on a word
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/wordnik/resource_modules/word.rb', line 251 def get_comment_count(word, *args) http_method = :get path = '/word/{word}/commentCount' 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 |
#get_comment_on_word(word, commentId, *args) ⇒ Object
Fetches a Comment by ID
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 |
# File 'lib/wordnik/resource_modules/word.rb', line 1007 def get_comment_on_word(word, commentId, *args) http_method = :get path = '/word/{word}/comment/{commentId}' path.sub!('{word}', word.to_s) path.sub!('{commentId}', commentId.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 |
#get_comments_on_word(word, *args) ⇒ Object
Fetches comments on a Word
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 |
# File 'lib/wordnik/resource_modules/word.rb', line 980 def get_comments_on_word(word, *args) http_method = :get path = '/word/{word}/comments' 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 |
#get_definitions(word, *args) ⇒ Object
Return definitions for a word
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/wordnik/resource_modules/word.rb', line 143 def get_definitions(word, *args) http_method = :get path = '/word/{word}/definitions' 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 |
#get_entries(word, *args) ⇒ Object
Return entries for a word
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/wordnik/resource_modules/word.rb', line 8 def get_entries(word, *args) http_method = :get path = '/word/{word}/entries' 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 |
#get_etymologies(word, *args) ⇒ Object
Fetches etymology data
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 |
# File 'lib/wordnik/resource_modules/word.rb', line 953 def get_etymologies(word, *args) http_method = :get path = '/word/{word}/etymologies' 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 |
#get_examples(word, *args) ⇒ Object
Returns examples for a word
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/wordnik/resource_modules/word.rb', line 35 def get_examples(word, *args) http_method = :get path = '/word/{word}/examples' 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 |
#get_examples_post(word, body, *args) ⇒ Object
Fetches examples for a word
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/wordnik/resource_modules/word.rb', line 62 def get_examples_post(word, body, *args) http_method = :post path = '/word/{word}/examples' 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 |
#get_favorite_count(word, *args) ⇒ Object
Returns the number of times a word has been Favorited
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/wordnik/resource_modules/word.rb', line 818 def get_favorite_count(word, *args) http_method = :get path = '/word/{word}/favoriteCount' 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 |
#get_first_listed_by(word, *args) ⇒ Object
Returns the first User to list a particular word
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'lib/wordnik/resource_modules/word.rb', line 386 def get_first_listed_by(word, *args) http_method = :get path = '/word/{word}/firstListedBy' 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 |
#get_first_listed_in(word, *args) ⇒ Object
Returns the first WordList a word appeared in
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/wordnik/resource_modules/word.rb', line 359 def get_first_listed_in(word, *args) http_method = :get path = '/word/{word}/firstListedIn' 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 |
#get_first_usage_of_word(word, *args) ⇒ Object
Returns first usage of a word
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
# File 'lib/wordnik/resource_modules/word.rb', line 737 def get_first_usage_of_word(word, *args) http_method = :get path = '/word/{word}/firstUsed' 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 |
#get_flickr_images(word, *args) ⇒ Object
Returns Flickr images for a word
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/wordnik/resource_modules/word.rb', line 440 def get_flickr_images(word, *args) http_method = :get path = '/word/{word}/images/flickr' 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 |
#get_hyphenation(word, *args) ⇒ Object
Returns syllable information for a word
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'lib/wordnik/resource_modules/word.rb', line 521 def get_hyphenation(word, *args) http_method = :get path = '/word/{word}/hyphenation' 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 |
#get_listed_in(word, *args) ⇒ Object
Returns WordLists containing a word
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/wordnik/resource_modules/word.rb', line 305 def get_listed_in(word, *args) http_method = :get path = '/word/{word}/listedIn' 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 |
#get_listed_in_count(word, *args) ⇒ Object
Returns a count of lists a word appears in
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/wordnik/resource_modules/word.rb', line 332 def get_listed_in_count(word, *args) http_method = :get path = '/word/{word}/listedInCount' 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 |
#get_lookup_count(word, *args) ⇒ Object
Returns the number of times a word has been viewed
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/wordnik/resource_modules/word.rb', line 224 def get_lookup_count(word, *args) http_method = :get path = '/word/{word}/lookupCount' 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 |
#get_phrases(word, *args) ⇒ Object
Fetches bi-gram phrases for a word
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
# File 'lib/wordnik/resource_modules/word.rb', line 899 def get_phrases(word, *args) http_method = :get path = '/word/{word}/phrases' 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 |
#get_pronunciation(word, pronId, *args) ⇒ Object
Fetches single audio pronunciation. 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.
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
# File 'lib/wordnik/resource_modules/word.rb', line 1173 def get_pronunciation(word, pronId, *args) http_method = :get path = '/word/{word}/pronunciation/{pronId}' path.sub!('{word}', word.to_s) path.sub!('{pronId}', pronId.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 |
#get_related(word, *args) ⇒ Object
Return related words (thesaurus data) for a word
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
# File 'lib/wordnik/resource_modules/word.rb', line 926 def (word, *args) http_method = :get path = '/word/{word}/related' 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 |
#get_related_words(word, *args) ⇒ Object
Given a word as a string, returns relationships from the Word Graph
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/wordnik/resource_modules/word.rb', line 278 def (word, *args) http_method = :get 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'} 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 |
#get_scrabble_score(word, *args) ⇒ Object
Returns the Scrabble score for a word
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/wordnik/resource_modules/word.rb', line 467 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 |
#get_tag_count_on_word(word, *args) ⇒ Object
Fetches tag count for a word
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
# File 'lib/wordnik/resource_modules/word.rb', line 629 def get_tag_count_on_word(word, *args) http_method = :get path = '/word/{word}/tagCount' 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 |
#get_tags_on_word(word, *args) ⇒ Object
Fetches tags for a word
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
# File 'lib/wordnik/resource_modules/word.rb', line 602 def (word, *args) http_method = :get path = '/word/{word}/tags' 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 |
#get_text_pronunciations(word, *args) ⇒ Object
Returns text pronunciations for a given word
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/wordnik/resource_modules/word.rb', line 413 def get_text_pronunciations(word, *args) http_method = :get path = '/word/{word}/pronunciations' 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 |
#get_top_example(word, *args) ⇒ Object
Returns a top example for a word
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/wordnik/resource_modules/word.rb', line 197 def get_top_example(word, *args) http_method = :get path = '/word/{word}/topExample' 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 |
#get_unigram_count_internal(word, *args) ⇒ Object
Returns syllable information for a word
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
# File 'lib/wordnik/resource_modules/word.rb', line 548 def get_unigram_count_internal(word, *args) http_method = :get path = '/word/{word}/unigramCountInternal' 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 |
#get_word(word, *args) ⇒ Object
Given a word as a string, returns the WordObject that represents it
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/wordnik/resource_modules/word.rb', line 116 def get_word(word, *args) http_method = :get path = '/word/{word}' 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 |
#get_word_forms(word, *args) ⇒ Object
Returns other forms of a word
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/wordnik/resource_modules/word.rb', line 89 def get_word_forms(word, *args) http_method = :get path = '/word/{word}/wordForms' 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 |
#get_word_frequency(word, *args) ⇒ Object
Returns word usage over time
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 |
# File 'lib/wordnik/resource_modules/word.rb', line 710 def get_word_frequency(word, *args) http_method = :get path = '/word/{word}/frequency' 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 |
#get_word_stats(word, *args) ⇒ Object
Returns word statistics
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/wordnik/resource_modules/word.rb', line 170 def get_word_stats(word, *args) http_method = :get path = '/word/{word}/stats' 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 |
#is_favorite(word, *args) ⇒ Object
Checks to see if a word is a user’s favorite
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/wordnik/resource_modules/word.rb', line 791 def is_favorite(word, *args) http_method = :get path = '/word/{word}/isFavorite' 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 |
#update_audio_internal(word, body, *args) ⇒ Object
Internal method to update an audio object
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 |
# File 'lib/wordnik/resource_modules/word.rb', line 1201 def update_audio_internal(word, body, *args) http_method = :put path = '/word/{word}/audioInternal' 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 |
#update_comment_on_word(word, body, *args) ⇒ Object
Updates an existing word comment
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 |
# File 'lib/wordnik/resource_modules/word.rb', line 1090 def update_comment_on_word(word, body, *args) http_method = :put path = '/word/{word}/comment' 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 |