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

Methods

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

External Aliases

filename -> ident

Attributes

filename  [R] 

Public Class methods

[Source]

# File lib/tmail/port.rb, line 50
    def initialize( fname )
      @filename = File.expand_path(fname)
      super()
    end

Public Instance methods

[Source]

# File lib/tmail/port.rb, line 59
    def ==( other )
      other.respond_to?(:filename) and @filename == other.filename
    end

[Source]

# File lib/tmail/port.rb, line 90
    def aopen( &block )
      File.open(@filename, 'a', &block)
    end

[Source]

# File lib/tmail/port.rb, line 117
    def copy_to( port )
      if FilePort === port
        copy_file @filename, port.filename
      else
        File.open(@filename) {|r|
        port.wopen {|w|
            while s = r.sysread(4096)
              w.write << s
            end
        } }
      end
    end
cp( port )

Alias for copy_to

eql?( other )

Alias for #==

[Source]

# File lib/tmail/port.rb, line 65
    def hash
      @filename.hash
    end

[Source]

# File lib/tmail/port.rb, line 69
    def inspect
      "#<#{self.class}:#{@filename}>"
    end

[Source]

# File lib/tmail/port.rb, line 106
    def move_to( port )
      begin
        File.link @filename, port.filename
      rescue Errno::EXDEV
        copy_to port
      end
      File.unlink @filename
    end
mv( port )

Alias for move_to

[Source]

# File lib/tmail/port.rb, line 95
    def read_all
      ropen {|f|
          return f.read
      }
    end

[Source]

# File lib/tmail/port.rb, line 102
    def remove
      File.unlink @filename
    end

[Source]

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

[Source]

# File lib/tmail/port.rb, line 82
    def ropen( &block )
      File.open(@filename, &block)
    end

[Source]

# File lib/tmail/port.rb, line 77
    def size
      File.size @filename
    end

[Source]

# File lib/tmail/port.rb, line 86
    def wopen( &block )
      File.open(@filename, 'w', &block)
    end

[Validate]