Class: TDiary::Request

Inherits:
Rack::Request
  • Object
show all
Includes:
RequestExtension
Defined in:
lib/tdiary/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RequestExtension

#mobile_agent?, #smartphone?

Constructor Details

#initialize(env, cgi = nil) ⇒ Request

Returns a new instance of Request.



8
9
10
11
# File 'lib/tdiary/request.rb', line 8

def initialize( env, cgi = nil )
	@env = env
	@cgi = cgi
end

Instance Attribute Details

#cgiObject (readonly)

Returns the value of attribute cgi.



6
7
8
# File 'lib/tdiary/request.rb', line 6

def cgi
  @cgi
end

#envObject (readonly)

Returns the value of attribute env.



6
7
8
# File 'lib/tdiary/request.rb', line 6

def env
  @env
end

Instance Method Details

#[](key) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/tdiary/request.rb', line 34

def []( key )
	if @cgi
		params[key.to_s]
	else
		super
	end
end

#[]=(key, val) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/tdiary/request.rb', line 42

def []=( key, val )
	if @cgi
		params[key.to_s] = val
	else
		super
	end
end

#accept_encodingObject



114
115
116
117
118
119
120
# File 'lib/tdiary/request.rb', line 114

def accept_encoding
	if @cgi
		raise NameError, 'not implemented : accept_encoding'
	else
		super
	end
end

#base_urlObject



345
346
347
348
349
350
351
# File 'lib/tdiary/request.rb', line 345

def base_url
	if @cgi
		@cgi.base_url
	else
		super
	end
end

#bodyObject



122
123
124
125
126
127
128
# File 'lib/tdiary/request.rb', line 122

def body
	if @cgi
		raise NameError, 'not implemented : body'
	else
		super
	end
end

#content_charsetObject



130
131
132
133
134
135
136
# File 'lib/tdiary/request.rb', line 130

def content_charset
	if @cgi
		@env['CONTENT_CHARSET']
	else
		super
	end
end

#content_lengthObject



138
139
140
141
142
143
144
# File 'lib/tdiary/request.rb', line 138

def content_length
	if @cgi
		@env['CONTENT_LENGTH']
	else
		super
	end
end

#content_typeObject



146
147
148
149
150
151
152
# File 'lib/tdiary/request.rb', line 146

def content_type
	if @cgi
		@env['CONTENT_TYPE']
	else
		super
	end
end

#cookiesObject



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/tdiary/request.rb', line 162

def cookies
	if @cgi
		return @cookies if @cookies
		@cookies = { }
		@cgi.cookies.each{|k, v|
			case v.size
			when 0
				@cookies[k] = nil
			when 1
				@cookies[k] = v[0]
			else
				@cookies[k] = v
			end
		}
		@cookies
	else
		super
	end
end

#delete?Boolean

Returns:

  • (Boolean)


98
99
100
101
102
103
104
# File 'lib/tdiary/request.rb', line 98

def delete?
	if @cgi
		request_method == 'DELETE'
	else
		super
	end
end

#form_data?Boolean

Returns:

  • (Boolean)


182
183
184
185
186
187
188
# File 'lib/tdiary/request.rb', line 182

def form_data?
	if @cgi
		raise NameError, 'not implemented : form_data?'
	else
		super
	end
end

#fullpathObject



190
191
192
193
194
195
196
# File 'lib/tdiary/request.rb', line 190

def fullpath
	if @cgi
		raise NameError, 'not implemented : fullpath'
	else
		super
	end
end

#get?Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
# File 'lib/tdiary/request.rb', line 66

def get?
	if @cgi
		request_method == 'GET'
	else
		super
	end
end

#head?Boolean

Returns:

  • (Boolean)


74
75
76
77
78
79
80
# File 'lib/tdiary/request.rb', line 74

def head?
	if @cgi
		request_method == 'HEAD'
	else
		super
	end
end

#header(header) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/tdiary/request.rb', line 58

def header( header )
	if @cgi
		@cgi.header( header )
	else
		super
	end
end

#hostObject



198
199
200
201
202
203
204
205
# File 'lib/tdiary/request.rb', line 198

def host
	if @cgi
		# Remove port number.from Rack::Response
		( @env["HTTP_HOST"] || @env["SERVER_NAME"] ).gsub( /:\d+\z/, '' )
	else
		super
	end
end

#ipObject Also known as: remote_addr



207
208
209
210
211
212
213
# File 'lib/tdiary/request.rb', line 207

def ip
	if @cgi
		raise NameError, 'not implemented : ip'
	else
		super
	end
end

#media_typeObject



216
217
218
219
220
221
222
# File 'lib/tdiary/request.rb', line 216

def media_type
	if @cgi
		raise NameError, 'not implemented : madia_type'
	else
		super
	end
end

#media_type_paramsObject



224
225
226
227
228
229
230
# File 'lib/tdiary/request.rb', line 224

def media_type_params
	if @cgi
		raise NameError, 'not implemented : media_type_params'
	else
		super
	end
end

#openid_requestObject



232
233
234
235
236
237
238
# File 'lib/tdiary/request.rb', line 232

def openid_request
	if @cgi
		raise NameError, 'not implemented : openid_request'
	else
		super
	end
end

#openid_responseObject



240
241
242
243
244
245
246
# File 'lib/tdiary/request.rb', line 240

def openid_response
	if @cgi
		raise NameError, 'not implemented : openid_response'
	else
		super
	end
end

#paramsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tdiary/request.rb', line 13

def params
	if @cgi
		return @params if @params
		@params = { }
		@cgi.params.each{|k, v|
			v = v.uniq
			case v.size
			when 0
				@params[k] = nil
			when 1
				@params[k] = v[0]
			else
				@params[k] = v
			end
		}
		@params
	else
		super
	end
end

#parseable_data?Boolean

Returns:

  • (Boolean)


248
249
250
251
252
253
254
# File 'lib/tdiary/request.rb', line 248

def parseable_data?
	if @cgi
		raise NameError, 'not implemented : parseable_data?'
	else
		super
	end
end

#pathObject



256
257
258
259
260
261
262
# File 'lib/tdiary/request.rb', line 256

def path
	if @cgi
		raise NameError, 'not implemented : path'
	else
		super
	end
end

#path_infoObject



264
265
266
267
268
269
270
# File 'lib/tdiary/request.rb', line 264

def path_info
if @cgi
	raise NameError, 'not implemented : path'
else
	super
end
w		end

#path_info=(s) ⇒ Object



272
273
274
275
276
277
278
# File 'lib/tdiary/request.rb', line 272

def path_info=( s )
	if @cgi
		raise NameError, 'not implemented : path_info='
	else
		super
	end
end

#portObject



280
281
282
283
284
285
286
# File 'lib/tdiary/request.rb', line 280

def port
	if @cgi
		raise NameError, 'not implemented : port'
	else
		super
	end
end

#post?Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
88
# File 'lib/tdiary/request.rb', line 82

def post?
	if @cgi
		request_method == 'POST'
	else
		super
	end
end

#put?Boolean

Returns:

  • (Boolean)


90
91
92
93
94
95
96
# File 'lib/tdiary/request.rb', line 90

def put?
	if @cgi
		request_method == 'PUT'
	else
		super
	end
end

#query_stringObject



288
289
290
291
292
293
294
# File 'lib/tdiary/request.rb', line 288

def query_string
	if @cgi
		raise NameError, 'not implemented : query_string'
	else
		super
	end
end

#refererObject Also known as: referrer



296
297
298
299
300
301
302
# File 'lib/tdiary/request.rb', line 296

def referer
	if @cgi
		raise NameError, 'not implemented : referer'
	else
		super
	end
end

#request_methodObject



50
51
52
53
54
55
56
# File 'lib/tdiary/request.rb', line 50

def request_method
	if @cgi
		@env['REQUEST_METHOD']
	else
		super
	end
end

#schemaObject



305
306
307
308
309
310
311
# File 'lib/tdiary/request.rb', line 305

def schema
	if @cgi
		raise NameError, 'not implemented : schema'
	else
		super
	end
end

#script_nameObject



313
314
315
316
317
318
319
# File 'lib/tdiary/request.rb', line 313

def script_name
	if @cgi
		@env['SCRIPT_NAME']
	else
		super
	end
end

#session_optionsObject



321
322
323
324
325
326
327
# File 'lib/tdiary/request.rb', line 321

def session_options
	if @cgi
		raise NameError, 'not implemented : session_options'
	else
		super
	end
end

#urlObject



329
330
331
332
333
334
335
# File 'lib/tdiary/request.rb', line 329

def url
	if @cgi
		raise NameError, 'not implemented : url'
	else
		super
	end
end

#user_agentObject



337
338
339
340
341
342
343
# File 'lib/tdiary/request.rb', line 337

def user_agent
	if @cgi
		@cgi.user_agent
	else
		super
	end
end

#values_at(*keys) ⇒ Object



353
354
355
356
357
358
359
# File 'lib/tdiary/request.rb', line 353

def values_at( *keys )
	if @cgi
		raise NameError, 'not implemented : values_at'
	else
		super
	end
end

#xhr?Boolean

Returns:

  • (Boolean)


106
107
108
109
110
111
112
# File 'lib/tdiary/request.rb', line 106

def xhr?
	if @cgi
		@env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
	else
		super
	end
end