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 275
    def initialize(str = '')
      @buffer = str
      super()
    end

Public Instance methods

[Source]

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

[Source]

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

[Source]

# File lib/tmail/port.rb, line 334
    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 300
    def hash
      @buffer.object_id.hash
    end

[Source]

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

[Source]

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

Alias for to_s

[Source]

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

[Source]

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

Alias for remove

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]