Module: Mail::Parsers::MimeVersionParser

Defined in:
lib/mail/parsers/mime_version_parser.rb

Defined Under Namespace

Classes: MimeVersionStruct

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

._eof_actionsObject

Returns the value of attribute _eof_actions



172
173
174
# File 'lib/mail/parsers/mime_version_parser.rb', line 172

def _eof_actions
  @_eof_actions
end

._index_offsetsObject

Returns the value of attribute _index_offsets



39
40
41
# File 'lib/mail/parsers/mime_version_parser.rb', line 39

def _index_offsets
  @_index_offsets
end

._indiciesObject

Returns the value of attribute _indicies



49
50
51
# File 'lib/mail/parsers/mime_version_parser.rb', line 49

def _indicies
  @_indicies
end

._key_spansObject

Returns the value of attribute _key_spans



29
30
31
# File 'lib/mail/parsers/mime_version_parser.rb', line 29

def _key_spans
  @_key_spans
end

._trans_actionsObject

Returns the value of attribute _trans_actions



160
161
162
# File 'lib/mail/parsers/mime_version_parser.rb', line 160

def _trans_actions
  @_trans_actions
end

._trans_keysObject

Returns the value of attribute _trans_keys



14
15
16
# File 'lib/mail/parsers/mime_version_parser.rb', line 14

def _trans_keys
  @_trans_keys
end

._trans_targsObject

Returns the value of attribute _trans_targs



148
149
150
# File 'lib/mail/parsers/mime_version_parser.rb', line 148

def _trans_targs
  @_trans_targs
end

.en_comment_tailObject

Returns the value of attribute en_comment_tail



195
196
197
# File 'lib/mail/parsers/mime_version_parser.rb', line 195

def en_comment_tail
  @en_comment_tail
end

.en_mainObject

Returns the value of attribute en_main



199
200
201
# File 'lib/mail/parsers/mime_version_parser.rb', line 199

def en_main
  @en_main
end

.errorObject

Returns the value of attribute error



190
191
192
# File 'lib/mail/parsers/mime_version_parser.rb', line 190

def error
  @error
end

.first_finalObject

Returns the value of attribute first_final



186
187
188
# File 'lib/mail/parsers/mime_version_parser.rb', line 186

def first_final
  @first_final
end

.startObject

Returns the value of attribute start



182
183
184
# File 'lib/mail/parsers/mime_version_parser.rb', line 182

def start
  @start
end

Class Method Details

.parse(data) ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/mail/parsers/mime_version_parser.rb', line 205

def self.parse(data)
  return MimeVersionStruct.new('', nil) if Mail::Utilities.blank?(data)

  # Parser state
  mime_version = MimeVersionStruct.new
  major_digits_s = minor_digits_s = nil

  # 5.1 Variables Used by Ragel
  p = 0
  eof = pe = data.length
  stack = []

  
begin
	p ||= 0
	pe ||= data.length
	cs = start
	top = 0
end

  
begin
	testEof = false
	_slen, _trans, _keys, _inds, _acts, _nacts = nil
	_goto_level = 0
	_resume = 10
	_eof_trans = 15
	_again = 20
	_test_eof = 30
	_out = 40
	while true
	if _goto_level <= 0
	if p == pe
		_goto_level = _test_eof
		next
	end
	if cs == 0
		_goto_level = _out
		next
	end
	end
	if _goto_level <= _resume
	_keys = cs << 1
	_inds = _index_offsets[cs]
	_slen = _key_spans[cs]
	_wide = data[p].ord
	_trans = if (   _slen > 0 && 
			_trans_keys[_keys] <= _wide && 
			_wide <= _trans_keys[_keys + 1] 
  ) then
			_indicies[ _inds + _wide - _trans_keys[_keys] ] 
		 else 
			_indicies[ _inds + _slen ]
		 end
	cs = _trans_targs[_trans]
	if _trans_actions[_trans] != 0
	case _trans_actions[_trans]
	when 2 then
		begin
 major_digits_s = p 		end
	when 7 then
		begin
 mime_version.major = data[major_digits_s..(p-1)] 		end
	when 8 then
		begin
 minor_digits_s = p 		end
	when 14 then
		begin
 mime_version.minor = data[minor_digits_s..(p-1)] 		end
	when 10 then
		begin
		end
	when 3 then
		begin
		end
	when 1 then
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 11
		_goto_level = _again
		next
	end
 		end
	when 13 then
		begin
 	begin
		top -= 1
		cs = stack[top]
		_goto_level = _again
		next
	end
 		end
	when 6 then
		begin
 mime_version.major = data[major_digits_s..(p-1)] 		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 11
		_goto_level = _again
		next
	end
 		end
	when 15 then
		begin
 mime_version.minor = data[minor_digits_s..(p-1)] 		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 11
		_goto_level = _again
		next
	end
 		end
	when 11 then
		begin
		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 11
		_goto_level = _again
		next
	end
 		end
	when 12 then
		begin
		end
		begin
 	begin
		top -= 1
		cs = stack[top]
		_goto_level = _again
		next
	end
 		end
	when 5 then
		begin
		end
		begin
 major_digits_s = p 		end
	when 9 then
		begin
		end
		begin
 minor_digits_s = p 		end
	when 4 then
		begin
		end
		begin
 	begin
		stack[top] = cs
		top+= 1
		cs = 11
		_goto_level = _again
		next
	end
 		end
	end
	end
	end
	if _goto_level <= _again
	if cs == 0
		_goto_level = _out
		next
	end
	p += 1
	if p != pe
		_goto_level = _resume
		next
	end
	end
	if _goto_level <= _test_eof
	if p == eof
	  case _eof_actions[cs]
	when 14 then
		begin
 mime_version.minor = data[minor_digits_s..(p-1)] 		end
	when 3 then
		begin
		end
	  end
	end

	end
	if _goto_level <= _out
		break
	end
end
	end


  if p != eof || cs < 16
    raise Mail::Field::ParseError.new(Mail::MimeVersionElement, data, "Only able to parse up to #{data[0..p]}")
  end

  mime_version
end