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)


50
51
52
53
54
55
56
57
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 50

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.



65
66
67
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 65

def last_atime
  @last_atime
end

Instance Method Details

#closeObject



71
72
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 71

def close
end

#directoryObject Also known as: dirname



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

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



103
104
105
106
107
108
109
110
111
112
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 103

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



78
79
80
81
82
83
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 78

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

#inspectObject



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

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

#new_portObject Also known as: new_mail



74
75
76
# File 'lib/action_mailer/vendor/tmail/mailbox.rb', line 74

def new_port
  PORT_CLASS.new(next_file_name())
end

#reverse_each_portObject Also known as: reverse_each



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

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