Class: TMail::MhMailbox

Inherits:
Object show all
Defined in:
lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb,
lib/action_mailer/vendor/tmail-1.2.7/tmail/obsolete.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)


52
53
54
55
56
57
58
59
# File 'lib/action_mailer/vendor/tmail-1.2.7/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

Instance Attribute Details

#last_atimeObject

Returns the value of attribute last_atime.



67
68
69
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb', line 67

def last_atime
  @last_atime
end

Instance Method Details

#closeObject



73
74
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb', line 73

def close
end

#directoryObject Also known as: dirname



61
62
63
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb', line 61

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



105
106
107
108
109
110
111
112
113
114
# File 'lib/action_mailer/vendor/tmail-1.2.7/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

#each_portObject Also known as: each, each_mail



80
81
82
83
84
85
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb', line 80

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

#inspectObject



69
70
71
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb', line 69

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

#new_portObject Also known as: new_mail



76
77
78
# File 'lib/action_mailer/vendor/tmail-1.2.7/tmail/mailbox.rb', line 76

def new_port
  PORT_CLASS.new(next_file_name())
end

#reverse_each_portObject Also known as: reverse_each



89
90
91
92
93
94
# File 'lib/action_mailer/vendor/tmail-1.2.7/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