Module: UsersMethods

Defined in:
lib/wordnik/resource_modules/users.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

Instance Method Details

#create_user(body, *args) ⇒ Object

Creates a User



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/wordnik/resource_modules/users.rb', line 88

def create_user(body, *args)
  http_method = :post
  path = '/users'

  # 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

#find_users_by_criteria(*args) ⇒ Object

Finds users by activity criteria



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/wordnik/resource_modules/users.rb', line 192

def find_users_by_criteria(*args)
  http_method = :get
  path = '/users/find'

  # 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_by_facebook_id(facebookId, *args) ⇒ Object

Fetches a User by Facebook ID



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/wordnik/resource_modules/users.rb', line 61

def get_by_facebook_id(facebookId, *args)
  http_method = :get
  path = '/users/facebook/{facebookId}'
  path.sub!('{facebookId}', facebookId.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_recent_comments(*args) ⇒ Object

Fetches recent Comment objects



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/wordnik/resource_modules/users.rb', line 140

def get_recent_comments(*args)
  http_method = :get
  path = '/users/comments'

  # 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_recent_favorites(*args) ⇒ Object

Fetches recent Favorite Word objects.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/wordnik/resource_modules/users.rb', line 114

def get_recent_favorites(*args)
  http_method = :get
  path = '/users/favorites'

  # 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_recent_pronunciations(*args) ⇒ Object

Fetches recent AudioPron objects



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/wordnik/resource_modules/users.rb', line 8

def get_recent_pronunciations(*args)
  http_method = :get
  path = '/users/pronunciations'

  # 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_user_by_id(id, *args) ⇒ Object

Fetches a User by ID



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/wordnik/resource_modules/users.rb', line 34

def get_user_by_id(id, *args)
  http_method = :get
  path = '/users/id/{id}'
  path.sub!('{id}', 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

#get_users_who_listed_most_words(*args) ⇒ Object

Fetches info on Users who listed most words



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/wordnik/resource_modules/users.rb', line 166

def get_users_who_listed_most_words(*args)
  http_method = :get
  path = '/users/listedMostWords'

  # 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