Class: TMail::MhMailbox
- Defined in:
- lib/gems/tmail-1.2.3.1/lib/tmail/mailbox.rb,
lib/gems/tmail-1.2.3.1/lib/tmail/obsolete.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 def each_mail each_port do |port| yield Mail.new(port) end end.
- #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.
52 53 54 55 56 57 58 59 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/mailbox.rb', line 52 def initialize( dir ) edir = File.(dir) raise ArgumentError, "not directory: #{dir}"\ unless FileTest.directory? edir @dirname = edir @last_file = nil @last_atime = nil end |
Instance Attribute Details
#last_atime ⇒ Object
Returns the value of attribute last_atime.
67 68 69 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/mailbox.rb', line 67 def last_atime @last_atime end |
Instance Method Details
#close ⇒ Object
73 74 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/mailbox.rb', line 73 def close end |
#directory ⇒ Object Also known as: dirname
61 62 63 |
# File 'lib/gems/tmail-1.2.3.1/lib/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/gems/tmail-1.2.3.1/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 |
#each_port ⇒ Object Also known as: each, each_mail
80 81 82 83 84 85 |
# File 'lib/gems/tmail-1.2.3.1/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 ⇒ Object
69 70 71 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/mailbox.rb', line 69 def inspect "#<#{self.class} #{@dirname}>" end |
#new_port ⇒ Object Also known as: new_mail
76 77 78 |
# File 'lib/gems/tmail-1.2.3.1/lib/tmail/mailbox.rb', line 76 def new_port PORT_CLASS.new(next_file_name()) end |
#reverse_each_port ⇒ Object Also known as: reverse_each
89 90 91 92 93 94 |
# File 'lib/gems/tmail-1.2.3.1/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 |