class TMail::MhLoader
Constants
- PORT_CLASS
Attributes
last_atime[RW]
Public Class Methods
new( dir )
click to toggle source
# File lib/tmail/mailbox.rb, line 52 def initialize( dir ) edir = File.expand_path(dir) raise ArgumentError, "not directory: #{dir}" unless FileTest.directory? edir @dirname = edir @last_file = nil @last_atime = nil end
Public Instance Methods
close()
click to toggle source
# File lib/tmail/mailbox.rb, line 73 def close end
directory()
click to toggle source
# File lib/tmail/mailbox.rb, line 61 def directory @dirname end
Also aliased as: dirname
each_new_port( mtime = nil ) { |port_class| ... }
click to toggle source
old #each_mail returns Port
def #each_mail
each_port do |port| yield Mail.new(port) end
end
# File lib/tmail/mailbox.rb, line 105 def each_new_port( mtime = nil, &block ) mtime ||= @last_atime return each_port(&block) unless mtime return unless File.mtime(@dirname) >= mtime mail_files().each do |path| yield PORT_CLASS.new(path) if File.mtime(path) > mtime end @last_atime = Time.now end
Also aliased as: each_newmail
each_port() { |port_class| ... }
click to toggle source
# File lib/tmail/mailbox.rb, line 80 def each_port mail_files().each do |path| yield PORT_CLASS.new(path) end @last_atime = Time.now end
inspect()
click to toggle source
# File lib/tmail/mailbox.rb, line 69 def inspect "#<#{self.class} #{@dirname}>" end
new_port()
click to toggle source
# File lib/tmail/mailbox.rb, line 76 def new_port PORT_CLASS.new(next_file_name()) end
Also aliased as: new_mail
reverse_each_port() { |port_class| ... }
click to toggle source
# File lib/tmail/mailbox.rb, line 89 def reverse_each_port mail_files().reverse_each do |path| yield PORT_CLASS.new(path) end @last_atime = Time.now end
Also aliased as: reverse_each
Private Instance Methods
mail_files()
click to toggle source
# File lib/tmail/mailbox.rb, line 118 def mail_files Dir.entries(@dirname) .select {|s| /\A\d+\z/ === s } .map {|s| s.to_i } .sort .map {|i| "#{@dirname}/#{i}" } .select {|path| FileTest.file? path } end
next_file_name()
click to toggle source
# File lib/tmail/mailbox.rb, line 127 def next_file_name unless n = @last_file n = 0 Dir.entries(@dirname) .select {|s| /\A\d+\z/ === s } .map {|s| s.to_i }.sort .each do |i| next unless FileTest.file? "#{@dirname}/#{i}" n = i end end begin n += 1 end while FileTest.exist? "#{@dirname}/#{n}" @last_file = n "#{@dirname}/#{n}" end