wordnik 4.06.00 → 4.06.01
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -3
- data/api_docs/.gitkeep +0 -0
- data/api_docs/account.json +1 -0
- data/api_docs/corpus.json +1 -0
- data/api_docs/document.json +1 -0
- data/api_docs/partners.json +1 -0
- data/api_docs/tag.json +1 -0
- data/api_docs/user.json +1 -0
- data/api_docs/users.json +1 -0
- data/api_docs/word.json +1 -0
- data/api_docs/wordList.json +1 -0
- data/api_docs/wordLists.json +1 -0
- data/api_docs/words.json +1 -0
- data/lib/wordnik/resource_modules/.gitkeep +0 -0
- data/lib/wordnik/resource_modules/account.rb +486 -0
- data/lib/wordnik/resource_modules/corpus.rb +453 -0
- data/lib/wordnik/resource_modules/document.rb +167 -0
- data/lib/wordnik/resource_modules/partners.rb +339 -0
- data/lib/wordnik/resource_modules/tag.rb +59 -0
- data/lib/wordnik/resource_modules/user.rb +1207 -0
- data/lib/wordnik/resource_modules/users.rb +216 -0
- data/lib/wordnik/resource_modules/word.rb +1391 -0
- data/lib/wordnik/resource_modules/word_list.rb +574 -0
- data/lib/wordnik/resource_modules/word_lists.rb +139 -0
- data/lib/wordnik/resource_modules/words.rb +645 -0
- data/lib/wordnik/version.rb +1 -1
- metadata +24 -26
@@ -0,0 +1,139 @@
|
|
1
|
+
# HEY HACKER! THIS IS AN AUTO-GENERATED FILE.
|
2
|
+
# So don't bother editing it. To see how it's built, take a look at the Rakefile
|
3
|
+
|
4
|
+
module WordListsMethods
|
5
|
+
|
6
|
+
# Fetches WordList objects by name.
|
7
|
+
# The term supplied is effectively given a wildcard before and after so 'cat' becomes '%cat%'
|
8
|
+
#
|
9
|
+
def find_by_name(searchString, *args)
|
10
|
+
http_method = :get
|
11
|
+
path = '/wordLists/find/{searchString}'
|
12
|
+
path.sub!('{searchString}', searchString.to_s)
|
13
|
+
|
14
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
15
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
16
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
17
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
18
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
19
|
+
last_arg ||= {}
|
20
|
+
|
21
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
22
|
+
# that we want the request itself back, not the response body
|
23
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
24
|
+
request_only = true
|
25
|
+
last_arg.delete(:request_only)
|
26
|
+
end
|
27
|
+
|
28
|
+
params = last_arg
|
29
|
+
body ||= {}
|
30
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
31
|
+
request_only ? request : request.response.body
|
32
|
+
end
|
33
|
+
|
34
|
+
# Creates a WordList.
|
35
|
+
#
|
36
|
+
def create_word_list(body, *args)
|
37
|
+
http_method = :post
|
38
|
+
path = '/wordLists'
|
39
|
+
|
40
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
41
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
42
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
43
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
44
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
45
|
+
last_arg ||= {}
|
46
|
+
|
47
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
48
|
+
# that we want the request itself back, not the response body
|
49
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
50
|
+
request_only = true
|
51
|
+
last_arg.delete(:request_only)
|
52
|
+
end
|
53
|
+
|
54
|
+
params = last_arg
|
55
|
+
body ||= {}
|
56
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
57
|
+
request_only ? request : request.response.body
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns information about API parameters
|
61
|
+
#
|
62
|
+
def get_help(*args)
|
63
|
+
http_method = :get
|
64
|
+
path = '/wordLists'
|
65
|
+
|
66
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
67
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
68
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
69
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
70
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
71
|
+
last_arg ||= {}
|
72
|
+
|
73
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
74
|
+
# that we want the request itself back, not the response body
|
75
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
76
|
+
request_only = true
|
77
|
+
last_arg.delete(:request_only)
|
78
|
+
end
|
79
|
+
|
80
|
+
params = last_arg
|
81
|
+
body ||= {}
|
82
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
83
|
+
request_only ? request : request.response.body
|
84
|
+
end
|
85
|
+
|
86
|
+
# Fetches a CommentSummary for WordList objects.
|
87
|
+
# The CommentSummary is sorted by comment count, descending
|
88
|
+
#
|
89
|
+
def find_most_commented_on(*args)
|
90
|
+
http_method = :get
|
91
|
+
path = '/wordLists/mostCommentedOn'
|
92
|
+
|
93
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
94
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
95
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
96
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
97
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
98
|
+
last_arg ||= {}
|
99
|
+
|
100
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
101
|
+
# that we want the request itself back, not the response body
|
102
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
103
|
+
request_only = true
|
104
|
+
last_arg.delete(:request_only)
|
105
|
+
end
|
106
|
+
|
107
|
+
params = last_arg
|
108
|
+
body ||= {}
|
109
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
110
|
+
request_only ? request : request.response.body
|
111
|
+
end
|
112
|
+
|
113
|
+
# Fetches recently created WordList objects.
|
114
|
+
#
|
115
|
+
def find_recent_lists(*args)
|
116
|
+
http_method = :get
|
117
|
+
path = '/wordLists/recentLists'
|
118
|
+
|
119
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
120
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
121
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
122
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
123
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
124
|
+
last_arg ||= {}
|
125
|
+
|
126
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
127
|
+
# that we want the request itself back, not the response body
|
128
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
129
|
+
request_only = true
|
130
|
+
last_arg.delete(:request_only)
|
131
|
+
end
|
132
|
+
|
133
|
+
params = last_arg
|
134
|
+
body ||= {}
|
135
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
136
|
+
request_only ? request : request.response.body
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
@@ -0,0 +1,645 @@
|
|
1
|
+
# HEY HACKER! THIS IS AN AUTO-GENERATED FILE.
|
2
|
+
# So don't bother editing it. To see how it's built, take a look at the Rakefile
|
3
|
+
|
4
|
+
module WordsMethods
|
5
|
+
|
6
|
+
# Searches words.
|
7
|
+
#
|
8
|
+
def search_words(*args)
|
9
|
+
http_method = :get
|
10
|
+
path = '/words/search'
|
11
|
+
|
12
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
13
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
14
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
15
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
16
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
17
|
+
last_arg ||= {}
|
18
|
+
|
19
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
20
|
+
# that we want the request itself back, not the response body
|
21
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
22
|
+
request_only = true
|
23
|
+
last_arg.delete(:request_only)
|
24
|
+
end
|
25
|
+
|
26
|
+
params = last_arg
|
27
|
+
body ||= {}
|
28
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
29
|
+
request_only ? request : request.response.body
|
30
|
+
end
|
31
|
+
|
32
|
+
# Fetches a WordOfTheDayList by ID
|
33
|
+
#
|
34
|
+
def get_word_of_the_day_list(permalink, *args)
|
35
|
+
http_method = :get
|
36
|
+
path = '/words/wordOfTheDayList/{permalink}'
|
37
|
+
path.sub!('{permalink}', permalink.to_s)
|
38
|
+
|
39
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
40
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
41
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
42
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
43
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
44
|
+
last_arg ||= {}
|
45
|
+
|
46
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
47
|
+
# that we want the request itself back, not the response body
|
48
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
49
|
+
request_only = true
|
50
|
+
last_arg.delete(:request_only)
|
51
|
+
end
|
52
|
+
|
53
|
+
params = last_arg
|
54
|
+
body ||= {}
|
55
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
56
|
+
request_only ? request : request.response.body
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns a specific WordOfTheDay
|
60
|
+
#
|
61
|
+
def get_word_of_the_day(*args)
|
62
|
+
http_method = :get
|
63
|
+
path = '/words/wordOfTheDay'
|
64
|
+
|
65
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
66
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
67
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
68
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
69
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
70
|
+
last_arg ||= {}
|
71
|
+
|
72
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
73
|
+
# that we want the request itself back, not the response body
|
74
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
75
|
+
request_only = true
|
76
|
+
last_arg.delete(:request_only)
|
77
|
+
end
|
78
|
+
|
79
|
+
params = last_arg
|
80
|
+
body ||= {}
|
81
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
82
|
+
request_only ? request : request.response.body
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns information about API parameters
|
86
|
+
#
|
87
|
+
def get_help(*args)
|
88
|
+
http_method = :get
|
89
|
+
path = '/words'
|
90
|
+
|
91
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
92
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
93
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
94
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
95
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
96
|
+
last_arg ||= {}
|
97
|
+
|
98
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
99
|
+
# that we want the request itself back, not the response body
|
100
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
101
|
+
request_only = true
|
102
|
+
last_arg.delete(:request_only)
|
103
|
+
end
|
104
|
+
|
105
|
+
params = last_arg
|
106
|
+
body ||= {}
|
107
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
108
|
+
request_only ? request : request.response.body
|
109
|
+
end
|
110
|
+
|
111
|
+
# Searches definitions.
|
112
|
+
#
|
113
|
+
def search_definitions(*args)
|
114
|
+
http_method = :get
|
115
|
+
path = '/words/searchDefinitions'
|
116
|
+
|
117
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
118
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
119
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
120
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
121
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
122
|
+
last_arg ||= {}
|
123
|
+
|
124
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
125
|
+
# that we want the request itself back, not the response body
|
126
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
127
|
+
request_only = true
|
128
|
+
last_arg.delete(:request_only)
|
129
|
+
end
|
130
|
+
|
131
|
+
params = last_arg
|
132
|
+
body ||= {}
|
133
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
134
|
+
request_only ? request : request.response.body
|
135
|
+
end
|
136
|
+
|
137
|
+
# Searches dictionary entries.
|
138
|
+
#
|
139
|
+
def search_entries(*args)
|
140
|
+
http_method = :get
|
141
|
+
path = '/words/searchEntries'
|
142
|
+
|
143
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
144
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
145
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
146
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
147
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
148
|
+
last_arg ||= {}
|
149
|
+
|
150
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
151
|
+
# that we want the request itself back, not the response body
|
152
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
153
|
+
request_only = true
|
154
|
+
last_arg.delete(:request_only)
|
155
|
+
end
|
156
|
+
|
157
|
+
params = last_arg
|
158
|
+
body ||= {}
|
159
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
160
|
+
request_only ? request : request.response.body
|
161
|
+
end
|
162
|
+
|
163
|
+
# Fetches corpus-level word frequency
|
164
|
+
#
|
165
|
+
def get_frequency(*args)
|
166
|
+
http_method = :get
|
167
|
+
path = '/words/frequency'
|
168
|
+
|
169
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
170
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
171
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
172
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
173
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
174
|
+
last_arg ||= {}
|
175
|
+
|
176
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
177
|
+
# that we want the request itself back, not the response body
|
178
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
179
|
+
request_only = true
|
180
|
+
last_arg.delete(:request_only)
|
181
|
+
end
|
182
|
+
|
183
|
+
params = last_arg
|
184
|
+
body ||= {}
|
185
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
186
|
+
request_only ? request : request.response.body
|
187
|
+
end
|
188
|
+
|
189
|
+
# Fetches surface forms of a word
|
190
|
+
#
|
191
|
+
def get_surface_forms(*args)
|
192
|
+
http_method = :get
|
193
|
+
path = '/words/surfaceForms'
|
194
|
+
|
195
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
196
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
197
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
198
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
199
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
200
|
+
last_arg ||= {}
|
201
|
+
|
202
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
203
|
+
# that we want the request itself back, not the response body
|
204
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
205
|
+
request_only = true
|
206
|
+
last_arg.delete(:request_only)
|
207
|
+
end
|
208
|
+
|
209
|
+
params = last_arg
|
210
|
+
body ||= {}
|
211
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
212
|
+
request_only ? request : request.response.body
|
213
|
+
end
|
214
|
+
|
215
|
+
# Fetches a word by ID
|
216
|
+
# Deprecated.
|
217
|
+
#
|
218
|
+
def get_word_by_id(id, *args)
|
219
|
+
http_method = :get
|
220
|
+
path = '/words/id/{id}'
|
221
|
+
path.sub!('{id}', id.to_s)
|
222
|
+
|
223
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
224
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
225
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
226
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
227
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
228
|
+
last_arg ||= {}
|
229
|
+
|
230
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
231
|
+
# that we want the request itself back, not the response body
|
232
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
233
|
+
request_only = true
|
234
|
+
last_arg.delete(:request_only)
|
235
|
+
end
|
236
|
+
|
237
|
+
params = last_arg
|
238
|
+
body ||= {}
|
239
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
240
|
+
request_only ? request : request.response.body
|
241
|
+
end
|
242
|
+
|
243
|
+
# Returns a WordOfTheDay range
|
244
|
+
#
|
245
|
+
def get_word_of_the_day_range(*args)
|
246
|
+
http_method = :get
|
247
|
+
path = '/words/wordOfTheDay/range'
|
248
|
+
|
249
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
250
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
251
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
252
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
253
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
254
|
+
last_arg ||= {}
|
255
|
+
|
256
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
257
|
+
# that we want the request itself back, not the response body
|
258
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
259
|
+
request_only = true
|
260
|
+
last_arg.delete(:request_only)
|
261
|
+
end
|
262
|
+
|
263
|
+
params = last_arg
|
264
|
+
body ||= {}
|
265
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
266
|
+
request_only ? request : request.response.body
|
267
|
+
end
|
268
|
+
|
269
|
+
# Fetches canonical forms of a word
|
270
|
+
#
|
271
|
+
def get_canonical_forms(*args)
|
272
|
+
http_method = :get
|
273
|
+
path = '/words/canonicalForms'
|
274
|
+
|
275
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
276
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
277
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
278
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
279
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
280
|
+
last_arg ||= {}
|
281
|
+
|
282
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
283
|
+
# that we want the request itself back, not the response body
|
284
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
285
|
+
request_only = true
|
286
|
+
last_arg.delete(:request_only)
|
287
|
+
end
|
288
|
+
|
289
|
+
params = last_arg
|
290
|
+
body ||= {}
|
291
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
292
|
+
request_only ? request : request.response.body
|
293
|
+
end
|
294
|
+
|
295
|
+
# Searches words.
|
296
|
+
#
|
297
|
+
def search_words_new(query, *args)
|
298
|
+
http_method = :get
|
299
|
+
path = '/words/search/{query}'
|
300
|
+
path.sub!('{query}', query.to_s)
|
301
|
+
|
302
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
303
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
304
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
305
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
306
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
307
|
+
last_arg ||= {}
|
308
|
+
|
309
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
310
|
+
# that we want the request itself back, not the response body
|
311
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
312
|
+
request_only = true
|
313
|
+
last_arg.delete(:request_only)
|
314
|
+
end
|
315
|
+
|
316
|
+
params = last_arg
|
317
|
+
body ||= {}
|
318
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
319
|
+
request_only ? request : request.response.body
|
320
|
+
end
|
321
|
+
|
322
|
+
# Returns an array of random WordObjects, in the format specified by the URL
|
323
|
+
#
|
324
|
+
def get_random_words(*args)
|
325
|
+
http_method = :get
|
326
|
+
path = '/words/randomWords'
|
327
|
+
|
328
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
329
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
330
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
331
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
332
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
333
|
+
last_arg ||= {}
|
334
|
+
|
335
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
336
|
+
# that we want the request itself back, not the response body
|
337
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
338
|
+
request_only = true
|
339
|
+
last_arg.delete(:request_only)
|
340
|
+
end
|
341
|
+
|
342
|
+
params = last_arg
|
343
|
+
body ||= {}
|
344
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
345
|
+
request_only ? request : request.response.body
|
346
|
+
end
|
347
|
+
|
348
|
+
# Returns a single random WordObject, in the format specified by the URL
|
349
|
+
#
|
350
|
+
def get_random_word(*args)
|
351
|
+
http_method = :get
|
352
|
+
path = '/words/randomWord'
|
353
|
+
|
354
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
355
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
356
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
357
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
358
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
359
|
+
last_arg ||= {}
|
360
|
+
|
361
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
362
|
+
# that we want the request itself back, not the response body
|
363
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
364
|
+
request_only = true
|
365
|
+
last_arg.delete(:request_only)
|
366
|
+
end
|
367
|
+
|
368
|
+
params = last_arg
|
369
|
+
body ||= {}
|
370
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
371
|
+
request_only ? request : request.response.body
|
372
|
+
end
|
373
|
+
|
374
|
+
# Fetches examples for multiple words.
|
375
|
+
#
|
376
|
+
def get_examples_for_words(body, *args)
|
377
|
+
http_method = :post
|
378
|
+
path = '/words/examples'
|
379
|
+
|
380
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
381
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
382
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
383
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
384
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
385
|
+
last_arg ||= {}
|
386
|
+
|
387
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
388
|
+
# that we want the request itself back, not the response body
|
389
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
390
|
+
request_only = true
|
391
|
+
last_arg.delete(:request_only)
|
392
|
+
end
|
393
|
+
|
394
|
+
params = last_arg
|
395
|
+
body ||= {}
|
396
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
397
|
+
request_only ? request : request.response.body
|
398
|
+
end
|
399
|
+
|
400
|
+
# Fetches words most commented on.
|
401
|
+
# Set the dayInterval to determine the time frame.
|
402
|
+
#
|
403
|
+
def get_words_most_commented_on(*args)
|
404
|
+
http_method = :get
|
405
|
+
path = '/words/mostCommentedOn'
|
406
|
+
|
407
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
408
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
409
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
410
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
411
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
412
|
+
last_arg ||= {}
|
413
|
+
|
414
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
415
|
+
# that we want the request itself back, not the response body
|
416
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
417
|
+
request_only = true
|
418
|
+
last_arg.delete(:request_only)
|
419
|
+
end
|
420
|
+
|
421
|
+
params = last_arg
|
422
|
+
body ||= {}
|
423
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
424
|
+
request_only ? request : request.response.body
|
425
|
+
end
|
426
|
+
|
427
|
+
# Fetches words most commented on.
|
428
|
+
# Set the dayInterval to determine the time frame.
|
429
|
+
#
|
430
|
+
def get_words_most_commented_on(statsType, object, *args)
|
431
|
+
http_method = :get
|
432
|
+
path = '/words/firstUsed/{statsType}/{object}'
|
433
|
+
path.sub!('{statsType}', statsType.to_s)
|
434
|
+
path.sub!('{object}', object.to_s)
|
435
|
+
|
436
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
437
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
438
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
439
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
440
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
441
|
+
last_arg ||= {}
|
442
|
+
|
443
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
444
|
+
# that we want the request itself back, not the response body
|
445
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
446
|
+
request_only = true
|
447
|
+
last_arg.delete(:request_only)
|
448
|
+
end
|
449
|
+
|
450
|
+
params = last_arg
|
451
|
+
body ||= {}
|
452
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
453
|
+
request_only ? request : request.response.body
|
454
|
+
end
|
455
|
+
|
456
|
+
# Invites users to a WordOfTheDayList
|
457
|
+
# A user can invite up to 20 people in a single day. The users being invited will be checked to see if they have opted out of email communications
|
458
|
+
#
|
459
|
+
def invite_to_word_of_the_day_list(permalink, body, *args)
|
460
|
+
http_method = :post
|
461
|
+
path = '/words/wordOfTheDayList/{permalink}/invite'
|
462
|
+
path.sub!('{permalink}', permalink.to_s)
|
463
|
+
|
464
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
465
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
466
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
467
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
468
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
469
|
+
last_arg ||= {}
|
470
|
+
|
471
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
472
|
+
# that we want the request itself back, not the response body
|
473
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
474
|
+
request_only = true
|
475
|
+
last_arg.delete(:request_only)
|
476
|
+
end
|
477
|
+
|
478
|
+
params = last_arg
|
479
|
+
body ||= {}
|
480
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
481
|
+
request_only ? request : request.response.body
|
482
|
+
end
|
483
|
+
|
484
|
+
# Fetches recently created WordOfTheDayLists
|
485
|
+
#
|
486
|
+
def get_recent_word_of_the_day_lists(*args)
|
487
|
+
http_method = :get
|
488
|
+
path = '/words/wordOfTheDayLists/recent'
|
489
|
+
|
490
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
491
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
492
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
493
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
494
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
495
|
+
last_arg ||= {}
|
496
|
+
|
497
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
498
|
+
# that we want the request itself back, not the response body
|
499
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
500
|
+
request_only = true
|
501
|
+
last_arg.delete(:request_only)
|
502
|
+
end
|
503
|
+
|
504
|
+
params = last_arg
|
505
|
+
body ||= {}
|
506
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
507
|
+
request_only ? request : request.response.body
|
508
|
+
end
|
509
|
+
|
510
|
+
# Fetches a WordOfTheDayList by ID
|
511
|
+
#
|
512
|
+
def get_word_of_the_day_list_item(permalink, specifier, *args)
|
513
|
+
http_method = :get
|
514
|
+
path = '/words/wordOfTheDayList/{permalink}/{specifier}'
|
515
|
+
path.sub!('{permalink}', permalink.to_s)
|
516
|
+
path.sub!('{specifier}', specifier.to_s)
|
517
|
+
|
518
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
519
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
520
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
521
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
522
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
523
|
+
last_arg ||= {}
|
524
|
+
|
525
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
526
|
+
# that we want the request itself back, not the response body
|
527
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
528
|
+
request_only = true
|
529
|
+
last_arg.delete(:request_only)
|
530
|
+
end
|
531
|
+
|
532
|
+
params = last_arg
|
533
|
+
body ||= {}
|
534
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
535
|
+
request_only ? request : request.response.body
|
536
|
+
end
|
537
|
+
|
538
|
+
# Fetches an array of WordOfTheDayList basd on a criteria
|
539
|
+
#
|
540
|
+
def get_word_of_the_day_lists_containing_word(*args)
|
541
|
+
http_method = :get
|
542
|
+
path = '/words/wordOfTheDayLists'
|
543
|
+
|
544
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
545
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
546
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
547
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
548
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
549
|
+
last_arg ||= {}
|
550
|
+
|
551
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
552
|
+
# that we want the request itself back, not the response body
|
553
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
554
|
+
request_only = true
|
555
|
+
last_arg.delete(:request_only)
|
556
|
+
end
|
557
|
+
|
558
|
+
params = last_arg
|
559
|
+
body ||= {}
|
560
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
561
|
+
request_only ? request : request.response.body
|
562
|
+
end
|
563
|
+
|
564
|
+
# Returns whether or not a subscription process has been run.
|
565
|
+
# Uses the current server time (day resolution) as the default date to check for, optionally a dateString can be supplied for a specific date to check for.
|
566
|
+
#
|
567
|
+
def get_word_of_the_day_list_subscription_process_status(*args)
|
568
|
+
http_method = :get
|
569
|
+
path = '/words/wordOfTheDayLists/subscriptionProcess'
|
570
|
+
|
571
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
572
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
573
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
574
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
575
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
576
|
+
last_arg ||= {}
|
577
|
+
|
578
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
579
|
+
# that we want the request itself back, not the response body
|
580
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
581
|
+
request_only = true
|
582
|
+
last_arg.delete(:request_only)
|
583
|
+
end
|
584
|
+
|
585
|
+
params = last_arg
|
586
|
+
body ||= {}
|
587
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
588
|
+
request_only ? request : request.response.body
|
589
|
+
end
|
590
|
+
|
591
|
+
# Subscribes a user to a WordOfTheDayList
|
592
|
+
#
|
593
|
+
def subscribe_to_list(permalink, body, *args)
|
594
|
+
http_method = :post
|
595
|
+
path = '/words/wordOfTheDayList/{permalink}/subscription'
|
596
|
+
path.sub!('{permalink}', permalink.to_s)
|
597
|
+
|
598
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
599
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
600
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
601
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
602
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
603
|
+
last_arg ||= {}
|
604
|
+
|
605
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
606
|
+
# that we want the request itself back, not the response body
|
607
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
608
|
+
request_only = true
|
609
|
+
last_arg.delete(:request_only)
|
610
|
+
end
|
611
|
+
|
612
|
+
params = last_arg
|
613
|
+
body ||= {}
|
614
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
615
|
+
request_only ? request : request.response.body
|
616
|
+
end
|
617
|
+
|
618
|
+
# Fetches WordOfTheDay objects for a specific date
|
619
|
+
#
|
620
|
+
def get_word_of_the_day_lists_for_date(date, *args)
|
621
|
+
http_method = :get
|
622
|
+
path = '/words/wordOfTheDayLists/{date}'
|
623
|
+
path.sub!('{date}', date.to_s)
|
624
|
+
|
625
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
626
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
627
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
628
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
629
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
630
|
+
last_arg ||= {}
|
631
|
+
|
632
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
633
|
+
# that we want the request itself back, not the response body
|
634
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
635
|
+
request_only = true
|
636
|
+
last_arg.delete(:request_only)
|
637
|
+
end
|
638
|
+
|
639
|
+
params = last_arg
|
640
|
+
body ||= {}
|
641
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
642
|
+
request_only ? request : request.response.body
|
643
|
+
end
|
644
|
+
|
645
|
+
end
|