Class: Hermeneutics::Box
- Inherits:
-
Object
- Object
- Hermeneutics::Box
- Includes:
- Enumerable
- Defined in:
- lib/hermeneutics/boxes.rb
Overview
Mailboxes
Class Attribute Summary collapse
-
.default_format ⇒ Object
Returns the value of attribute default_format.
Class Method Summary collapse
-
.check(path) ⇒ Object
:call-seq: Box.check( path) -> nil.
-
.find(path, default_format = nil) ⇒ Object
:call-seq: Box.find( path, default = nil) -> box.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
:call-seq: mbox.each { |mail| … } -> nil.
-
#exists? ⇒ Boolean
(also: #exist?)
:call-seq: box.exists? -> true or false.
-
#initialize(mailbox) ⇒ Box
constructor
:call-seq: Box.new( path) -> box.
- #path ⇒ Object
-
#store(msg) ⇒ Object
:call-seq: mbox.store( msg) -> nil.
- #to_s ⇒ Object
Constructor Details
#initialize(mailbox) ⇒ Box
:call-seq:
Box.new( path) -> box
Instantiate a Box object, just store the path
.
78 79 80 |
# File 'lib/hermeneutics/boxes.rb', line 78 def initialize mailbox @mailbox = mailbox end |
Class Attribute Details
.default_format ⇒ Object
Returns the value of attribute default_format.
33 34 35 |
# File 'lib/hermeneutics/boxes.rb', line 33 def default_format @default_format end |
Class Method Details
.check(path) ⇒ Object
:call-seq:
Box.check( path) -> nil
By default, subclass mailboxes do not exist. You should overwrite this behaviour.
62 63 |
# File 'lib/hermeneutics/boxes.rb', line 62 def check path end |
.find(path, default_format = nil) ⇒ Object
:call-seq:
Box.find( path, default = nil) -> box
Create a Box object (some subclass of Box), depending on what type the box is found at path
.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hermeneutics/boxes.rb', line 41 def find path, default_format = nil b = @boxes.find { |b| b.check path } b ||= default_format b ||= @default_format b ||= if File.directory? path then Maildir elsif File.file? path then MBox else # If still nothing was found use Postfix convention: path =~ /\/$/ ? Maildir : MBox end b.new path end |
Instance Method Details
#each(&block) ⇒ Object
:call-seq:
mbox.each { |mail| ... } -> nil
Iterate through MBox
. Alias for MBox#each_mail.
111 |
# File 'lib/hermeneutics/boxes.rb', line 111 def each &block ; each_mail &block ; end |
#exists? ⇒ Boolean Also known as: exist?
:call-seq:
box.exists? -> true or false
Test whether the Box
exists.
91 92 93 |
# File 'lib/hermeneutics/boxes.rb', line 91 def exists? self.class.check @mailbox end |
#path ⇒ Object
84 |
# File 'lib/hermeneutics/boxes.rb', line 84 def path ; @mailbox ; end |
#store(msg) ⇒ Object
:call-seq:
mbox.store( msg) -> nil
Store the mail to the local MBox
.
101 102 103 |
# File 'lib/hermeneutics/boxes.rb', line 101 def store msg store_raw msg.to_s, msg.plain_from, msg.created end |
#to_s ⇒ Object
82 |
# File 'lib/hermeneutics/boxes.rb', line 82 def to_s ; path ; end |