mbox.rb
Methods
- close
- directory
- dirname
- each
- each_mail
- each_new_port
- each_newmail
- each_port
- inspect
- mail_files
- new
- new_mail
- new_port
- next_file_name
- reverse_each
- reverse_each_port
Constants
| PORT_CLASS | = | MhPort |
Attributes
| [RW] | last_atime |
Public Class methods
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 31
31: def initialize( dir )
32: edir = File.expand_path(dir)
33: raise ArgumentError, "not directory: #{dir}"\
34: unless FileTest.directory? edir
35: @dirname = edir
36: @last_file = nil
37: @last_atime = nil
38: end
Public Instance methods
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 52
52: def close
53: end
This method is also aliased as
dirname
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 40
40: def directory
41: @dirname
42: end
Alias for directory
Alias for each_port
Alias for each_port
This method is also aliased as
each_newmail
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 84
84: def each_new_port( mtime = nil, &block )
85: mtime ||= @last_atime
86: return each_port(&block) unless mtime
87: return unless File.mtime(@dirname) >= mtime
88:
89: mail_files().each do |path|
90: yield PORT_CLASS.new(path) if File.mtime(path) > mtime
91: end
92: @last_atime = Time.now
93: end
Alias for each_new_port
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 59
59: def each_port
60: mail_files().each do |path|
61: yield PORT_CLASS.new(path)
62: end
63: @last_atime = Time.now
64: end
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 48
48: def inspect
49: "#<#{self.class} #{@dirname}>"
50: end
Alias for new_port
This method is also aliased as
new_mail
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 55
55: def new_port
56: PORT_CLASS.new(next_file_name())
57: end
Alias for reverse_each_port
This method is also aliased as
reverse_each
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 68
68: def reverse_each_port
69: mail_files().reverse_each do |path|
70: yield PORT_CLASS.new(path)
71: end
72: @last_atime = Time.now
73: end
Private Instance methods
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 97
97: def mail_files
98: Dir.entries(@dirname)\
99: .select {|s| /\A\d+\z/ === s }\
100: .map {|s| s.to_i }\
101: .sort\
102: .map {|i| "#{@dirname}/#{i}" }\
103: .select {|path| FileTest.file? path }
104: end
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 106
106: def next_file_name
107: unless n = @last_file
108: n = 0
109: Dir.entries(@dirname)\
110: .select {|s| /\A\d+\z/ === s }\
111: .map {|s| s.to_i }.sort\
112: .each do |i|
113: next unless FileTest.file? "#{@dirname}/#{i}"
114: n = i
115: end
116: end
117: begin
118: n += 1
119: end while FileTest.exist? "#{@dirname}/#{n}"
120: @last_file = n
121:
122: "#{@dirname}/#{n}"
123: end