Methods
- ==
- aopen
- copy_file
- copy_to
- cp
- eql?
- hash
- inspect
- move_to
- mv
- new
- read_all
- remove
- reproducible?
- ropen
- size
- wopen
Attributes
| [R] | filename |
Public Class methods
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 29
29: def initialize( fname )
30: @filename = File.expand_path(fname)
31: super()
32: end
Public Instance methods
This method is also aliased as
eql?
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 38
38: def ==( other )
39: other.respond_to?(:filename) and @filename == other.filename
40: end
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 69
69: def aopen( &block )
70: File.open(@filename, 'a', &block)
71: end
This method is also aliased as
cp
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 96
96: def copy_to( port )
97: if FilePort === port
98: copy_file @filename, port.filename
99: else
100: File.open(@filename) {|r|
101: port.wopen {|w|
102: while s = r.sysread(4096)
103: w.write << s
104: end
105: } }
106: end
107: end
Alias for copy_to
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 44
44: def hash
45: @filename.hash
46: end
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 48
48: def inspect
49: "#<#{self.class}:#{@filename}>"
50: end
This method is also aliased as
mv
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 85
85: def move_to( port )
86: begin
87: File.link @filename, port.filename
88: rescue Errno::EXDEV
89: copy_to port
90: end
91: File.unlink @filename
92: end
Alias for move_to
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 74
74: def read_all
75: ropen {|f|
76: return f.read
77: }
78: end
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 81
81: def remove
82: File.unlink @filename
83: end
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 52
52: def reproducible?
53: true
54: end
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 61
61: def ropen( &block )
62: File.open(@filename, &block)
63: end
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 56
56: def size
57: File.size @filename
58: end
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 65
65: def wopen( &block )
66: File.open(@filename, 'w', &block)
67: end
Private Instance methods
from fileutils.rb
[ show source ]
# File lib/action_mailer/vendor/tmail/port.rb, line 114
114: def copy_file( src, dest )
115: st = r = w = nil
116:
117: File.open(src, 'rb') {|r|
118: File.open(dest, 'wb') {|w|
119: st = r.stat
120: begin
121: while true
122: w.write r.sysread(st.blksize)
123: end
124: rescue EOFError
125: end
126: } }
127: end