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

StringPort

### 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

new( str = '' )

[Source]

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

### Public Instance methods

==( other )

[Source]

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

aopen( &block )

[Source]

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

copy_to( port )

[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 #==

hash()

[Source]

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

inspect()

[Source]

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

move_to( port )

[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

remove()

[Source]

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

reproducible?()

[Source]

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

rm()

Alias for remove

ropen( &block )

[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

size()

[Source]

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

string()

[Source]

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

to_s()

[Source]

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

wopen( &block )

[Source]

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

[Validate]