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 50
50: def initialize( dir )
51: edir = File.expand_path(dir)
52: raise ArgumentError, "not directory: #{dir}"\
53: unless FileTest.directory? edir
54: @dirname = edir
55: @last_file = nil
56: @last_atime = nil
57: end
Public Instance methods
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 71
71: def close
72: end
This method is also aliased as
dirname
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 59
59: def directory
60: @dirname
61: 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 103
103: def each_new_port( mtime = nil, &block )
104: mtime ||= @last_atime
105: return each_port(&block) unless mtime
106: return unless File.mtime(@dirname) >= mtime
107:
108: mail_files().each do |path|
109: yield PORT_CLASS.new(path) if File.mtime(path) > mtime
110: end
111: @last_atime = Time.now
112: end
Alias for each_new_port
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 78
78: def each_port
79: mail_files().each do |path|
80: yield PORT_CLASS.new(path)
81: end
82: @last_atime = Time.now
83: end
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 67
67: def inspect
68: "#<#{self.class} #{@dirname}>"
69: end
Alias for new_port
This method is also aliased as
new_mail
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 74
74: def new_port
75: PORT_CLASS.new(next_file_name())
76: 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 87
87: def reverse_each_port
88: mail_files().reverse_each do |path|
89: yield PORT_CLASS.new(path)
90: end
91: @last_atime = Time.now
92: end
Private Instance methods
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 116
116: def mail_files
117: Dir.entries(@dirname)\
118: .select {|s| /\A\d+\z/ === s }\
119: .map {|s| s.to_i }\
120: .sort\
121: .map {|i| "#{@dirname}/#{i}" }\
122: .select {|path| FileTest.file? path }
123: end
[ show source ]
# File lib/action_mailer/vendor/tmail/mailbox.rb, line 125
125: def next_file_name
126: unless n = @last_file
127: n = 0
128: Dir.entries(@dirname)\
129: .select {|s| /\A\d+\z/ === s }\
130: .map {|s| s.to_i }.sort\
131: .each do |i|
132: next unless FileTest.file? "#{@dirname}/#{i}"
133: n = i
134: end
135: end
136: begin
137: n += 1
138: end while FileTest.exist? "#{@dirname}/#{n}"
139: @last_file = n
140:
141: "#{@dirname}/#{n}"
142: end