Class: InternetMessage::TraceBlockList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/internet_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTraceBlockList

Returns a new instance of TraceBlockList.



359
360
361
362
363
# File 'lib/internet_message.rb', line 359

def initialize
  @block = TraceBlock.new
  @blocks = [@block]
  @state = nil
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



356
357
358
# File 'lib/internet_message.rb', line 356

def blocks
  @blocks
end

Instance Method Details

#cleanObject



391
392
393
# File 'lib/internet_message.rb', line 391

def clean
  @blocks.delete_if(&:empty?)
end

#eachObject



395
396
397
398
399
# File 'lib/internet_message.rb', line 395

def each
  @blocks.each do |b|
    yield b
  end
end

#push(field) ⇒ Object



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/internet_message.rb', line 366

def push(field)
  case field.name
  when 'return-path'
    @block = TraceBlock.new
    @blocks.push @block
    @block.push field
    @state = :return
  when 'received'
    unless @state == :return or @state == :received
      @block = TraceBlock.new
      @blocks.push @block
    end
    @block.push field
    @state = :received
  when /\Aresent-/
    unless @state == :return or @state == :received or @state == :resent
      @block = TraceBlock.new
      @blocks.push @block
    end
    @block.push field
    @state = :resent
  end
end