Class TMail::StringPort
In: lib/tmail/port.rb
Parent: Port

Methods

==   aopen   copy_to   cp   eql?   hash   inspect   move_to   new   read_all   remove   reproducible?   rm   ropen   size   string   to_s   wopen  

Public Class methods

[Source]

# File lib/tmail/port.rb, line 301
    def initialize( str = '' )
      @buffer = str
      super()
    end

Public Instance methods

[Source]

# File lib/tmail/port.rb, line 320
    def ==( other )
      StringPort === other and @buffer.equal? other.string
    end

[Source]

# File lib/tmail/port.rb, line 348
    def aopen( &block )
      @buffer ||= ''
      StringOutput.new(@buffer, &block)
    end

[Source]

# File lib/tmail/port.rb, line 359
    def copy_to( port )
      port.wopen {|f|
          f.write @buffer
      }
    end
cp( port )

Alias for copy_to

eql?( other )

Alias for #==

[Source]

# File lib/tmail/port.rb, line 326
    def hash
      @buffer.object_id.hash
    end

[Source]

# File lib/tmail/port.rb, line 330
    def inspect
      "#<#{self.class}:id=#{sprintf '0x%x', @buffer.object_id}>"
    end

[Source]

# File lib/tmail/port.rb, line 367
    def move_to( port )
      if StringPort === port
        str = @buffer
        port.instance_eval { @buffer = str }
      else
        copy_to port
      end
      remove
    end
read_all()

Alias for to_s

[Source]

# File lib/tmail/port.rb, line 353
    def remove
      @buffer = nil
    end

[Source]

# File lib/tmail/port.rb, line 334
    def reproducible?
      true
    end
rm()

Alias for remove

[Source]

# File lib/tmail/port.rb, line 338
    def ropen( &block )
      @buffer or raise Errno::ENOENT, "#{inspect} is already removed"
      StringInput.open(@buffer, &block)
    end

[Source]

# File lib/tmail/port.rb, line 316
    def size
      @buffer.size
    end

[Source]

# File lib/tmail/port.rb, line 306
    def string
      @buffer
    end

[Source]

# File lib/tmail/port.rb, line 310
    def to_s
      @buffer.dup
    end

[Source]

# File lib/tmail/port.rb, line 343
    def wopen( &block )
      @buffer = ''
      StringOutput.new(@buffer, &block)
    end

[Validate]