class
Maildir::Message
- Maildir::Message
- Reference
- Object
Included Modules
- Comparable(Maildir::Message)
Defined in:
message.crConstant Summary
-
COLON =
":" -
COLON seperates the unique name from the info
-
FLAG_NAMES =
{passed: "P", replied: "R", seen: "S", trashed: "T", draft: "D", flagged: "F"} -
The standard maildir flags, and the letters representing them.
-
INFO =
"2," -
The default info, to which flags are appended
Constructors
-
.new(maildir : Maildir, key : String | Nil = nil)
Create a new, unwritten message or instantiate an existing message.
Class Method Summary
-
.create(maildir, data)
Create a new message in maildir with data.
-
.parse_key(key : String) : Tuple(String, String, String | Nil)
Splits a key into its dir, unique name, and info parts.
-
.serializer
DEPRECATED Get the serializer.
-
.serializer=(serializer)
DEPRECATED Set the serializer.
Instance Method Summary
-
#<=>(other : self)
Compares messages by their paths.
-
#add_flag(flag)
Adds one or more flags to a message.
-
#data
Returns the message's data from disk.
-
#destroy
Deletes the message path.
- #dir : String
-
#draft!
Adds the "D" (draft) flag to the message.
-
#draft?
Returns true if the message carries the "D" (draft) flag.
-
#filename
Returns the filename of the message
-
#flagged!
Adds the "F" (flagged) flag to the message.
-
#flagged?
Returns true if the message carries the "F" (flagged) flag.
-
#flags : Array(String)
Returns an array of single letter flags applied to the message
-
#flags=(flags)
Sets the flags on a message.
-
#hash(hasher)
See
Object#hash(hasher) - #info : String | Nil
-
#info=(info)
Set info on a message.
-
#inspect(io : IO) : Nil
Friendly inspect method
-
#key
Returns the key to identify the message
-
#mtime
Returns the message's mtime, or false if the file doesn't exist.
-
#passed!
Adds the "P" (passed) flag to the message.
-
#passed?
Returns true if the message carries the "P" (passed) flag.
-
#path
Returns the full path to the message
-
#process
Move a message from new to cur, add info.
-
#remove_flag(flags)
Removes flags from a message.
-
#replied!
Adds the "R" (replied) flag to the message.
-
#replied?
Returns true if the message carries the "R" (replied) flag.
-
#seen!
Adds the "S" (seen) flag to the message.
-
#seen?
Returns true if the message carries the "S" (seen) flag.
-
#serializer
Helper to get serializer.
-
#trashed!
Adds the "T" (trashed) flag to the message.
-
#trashed?
Returns true if the message carries the "T" (trashed) flag.
- #unique_name : String
-
#utime(atime, mtime)
Updates the modification and access time.
-
#write(data)
Writes data to disk.
Constructor Detail
Create a new, unwritten message or instantiate an existing message. If key is nil, create a new message: Message.new(maildir) # => a new, unwritten message
If +key+ is not nil, instantiate a message object for the message at +key+. Message.new(maildir, key) # => an existing message
Class Method Detail
Create a new message in maildir with data. The message is first written to the tmp dir, then moved to new. This is a shortcut for: message = Maildir::Message.new(maildir) message.write(data)
Splits a key into its dir, unique name, and info parts. Raises ArgumentError if the key is not of the form "dir/unique_name[:info]".
Instance Method Detail
Adds one or more flags to a message. Returns the message's key if successful, false otherwise.
flag:: String or Enumerable of flags
Returns the message's data from disk. If the path doesn't exist, raises File::NotFoundError.
Deletes the message path. Returns nil if the file was destroyed, false if the file was missing.
Adds the "D" (draft) flag to the message. Returns the message's key if successful, false otherwise.
Adds the "F" (flagged) flag to the message. Returns the message's key if successful, false otherwise.
Sets the flags on a message. Returns the message's key if successful, false otherwise.
flags:: String or Enumerable of flags
Adds the "P" (passed) flag to the message. Returns the message's key if successful, false otherwise.
Removes flags from a message. Returns the message's key if successful, false otherwise.
flags:: String or Enumerable of flags
Adds the "R" (replied) flag to the message. Returns the message's key if successful, false otherwise.
Adds the "S" (seen) flag to the message. Returns the message's key if successful, false otherwise.
Adds the "T" (trashed) flag to the message. Returns the message's key if successful, false otherwise.
Updates the modification and access time. Returns nil if successful, false if the file doesn't exist.
Writes data to disk. Can only be called on messages instantiated without a key (which haven't been written to disk). After successfully writing to disk, rename the message to the new dir
Returns the message's key