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

FilePort

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

new( fname )

[Source]

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

### Public Instance methods

==( other )

[Source]

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

aopen( &block )

[Source]

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

copy_to( port )

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

hash()

[Source]

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

inspect()

[Source]

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

move_to( port )

[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

read_all()

[Source]

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

remove()

[Source]

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

reproducible?()

[Source]

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

ropen( &block )

[Source]

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

size()

[Source]

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

wopen( &block )

[Source]

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

[Validate]