Class: TMail::MhMailbox

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ MhMailbox

Returns a new instance of MhMailbox.

Raises:

  • (ArgumentError)


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.expand_path(dir)
  @last_file = nil
  @last_atime = nil
end

Instance Attribute Details

#last_atimeObject

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

#closeObject



42
43
# File 'lib/tmail-pure/mailbox.rb', line 42

def close
end

#directoryObject 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_portObject 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

#inspectObject



38
39
40
# File 'lib/tmail-pure/mailbox.rb', line 38

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

#new_portObject 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_portObject 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