Class: TMail::MhMailbox
- Inherits:
-
Object
- Object
- TMail::MhMailbox
- Defined in:
- lib/tmail-pure/obsolete.rb,
lib/tmail-pure/mailbox.rb
Overview
mbox.rb
Constant Summary collapse
- PORT_CLASS =
MhPort
Instance Attribute Summary collapse
-
#last_atime ⇒ Object
Returns the value of attribute last_atime.
Instance Method Summary collapse
- #close ⇒ Object
- #directory ⇒ Object (also: #dirname)
-
#each_new_port(mtime = nil, &block) ⇒ Object
(also: #each_newmail)
Old #each_mail returns Port, we cannot define this method now.
- #each_port ⇒ Object (also: #each, #each_mail)
-
#initialize(dir) ⇒ MhMailbox
constructor
A new instance of MhMailbox.
- #inspect ⇒ Object
- #new_port ⇒ Object (also: #new_mail)
- #reverse_each_port ⇒ Object (also: #reverse_each)
Constructor Details
#initialize(dir) ⇒ MhMailbox
Returns a new instance of MhMailbox.
23 24 25 26 27 28 |
# File 'lib/tmail-pure/mailbox.rb', line 23 def initialize(dir) raise ArgumentError, "not directory: #{dir}" unless File.directory?(dir) @dirname = File.(dir) @last_file = nil @last_atime = nil end |
Instance Attribute Details
#last_atime ⇒ Object
Returns the value of attribute last_atime.
36 37 38 |
# File 'lib/tmail-pure/mailbox.rb', line 36 def last_atime @last_atime end |
Instance Method Details
#close ⇒ Object
42 43 |
# File 'lib/tmail-pure/mailbox.rb', line 42 def close end |
#directory ⇒ Object Also known as: dirname
30 31 32 |
# File 'lib/tmail-pure/mailbox.rb', line 30 def directory @dirname end |
#each_new_port(mtime = nil, &block) ⇒ Object Also known as: each_newmail
Old #each_mail returns Port, we cannot define this method now. def each_mail
each_port do |port|
yield Mail.new(port)
end
end
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/tmail-pure/mailbox.rb', line 74 def each_new_port(mtime = nil, &block) mtime ||= @last_atime return each_port(&block) unless mtime return unless File.mtime(@dirname) >= mtime sorted_mail_entries(@dirname).each do |ent| path = "#{@dirname}/#{ent}" yield PORT_CLASS.new(path) if File.mtime(path) > mtime end @last_atime = Time.now end |
#each_port ⇒ Object Also known as: each, each_mail
49 50 51 52 53 54 |
# File 'lib/tmail-pure/mailbox.rb', line 49 def each_port sorted_mail_entries(@dirname).each do |ent| yield PORT_CLASS.new("#{@dirname}/#{ent}") end @last_atime = Time.now end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/tmail-pure/mailbox.rb', line 38 def inspect "#<#{self.class} #{@dirname}>" end |
#new_port ⇒ Object Also known as: new_mail
45 46 47 |
# File 'lib/tmail-pure/mailbox.rb', line 45 def new_port PORT_CLASS.new(next_file_name(@dirname)) end |
#reverse_each_port ⇒ Object Also known as: reverse_each
58 59 60 61 62 63 |
# File 'lib/tmail-pure/mailbox.rb', line 58 def reverse_each_port sorted_mail_entries(@dirname).reverse_each do |ent| yield PORT_CLASS.new("#{@dirname}/#{ent}") end @last_atime = Time.now end |