Class: TMail::MhMailbox

Inherits:
Object
  • Object
show all
Defined in:
lib/action_mailer/vendor/tmail/obsolete.rb,
lib/action_mailer/vendor/tmail/mailbox.rb

Overview

mbox.rb

Constant Summary collapse

PORT_CLASS =
MhPort

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ MhMailbox

Returns a new instance of MhMailbox.

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 31

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

Instance Attribute Details

#last_atimeObject

Returns the value of attribute last_atime.



46
47
48
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 46

def last_atime
  @last_atime
end

Instance Method Details

#closeObject



52
53
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 52

def close
end

#directoryObject Also known as: dirname



40
41
42
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 40

def directory
  @dirname
end

#each_new_port(mtime = nil, &block) ⇒ Object Also known as: each_newmail

old #each_mail returns Port def each_mail

each_port do |port|
  yield Mail.new(port)
end

end



84
85
86
87
88
89
90
91
92
93
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 84

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

#each_portObject Also known as: each, each_mail



59
60
61
62
63
64
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 59

def each_port
  mail_files().each do |path|
    yield PORT_CLASS.new(path)
  end
  @last_atime = Time.now
end

#inspectObject



48
49
50
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 48

def inspect
  "#<#{self.class} #{@dirname}>"
end

#new_portObject Also known as: new_mail



55
56
57
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 55

def new_port
  PORT_CLASS.new(next_file_name())
end

#reverse_each_portObject Also known as: reverse_each



68
69
70
71
72
73
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 68

def reverse_each_port
  mail_files().reverse_each do |path|
    yield PORT_CLASS.new(path)
  end
  @last_atime = Time.now
end