class Maildir::Message

Included Modules

Defined in:

message.cr

Constant 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

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(maildir : Maildir, key : String | Nil = nil) #

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


[View source]

Class Method Detail

def self.create(maildir, data) #

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)


[View source]
def self.parse_key(key : String) : Tuple(String, String, String | Nil) #

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]".


[View source]
def self.serializer #

DEPRECATED Get the serializer. @see Maildir.serializer


[View source]
def self.serializer=(serializer) #

DEPRECATED Set the serializer. @see Maildir.serializer=


[View source]

Instance Method Detail

def <=>(other : self) #

Compares messages by their paths. Returns 1, 0, or -1.


[View source]
def add_flag(flag) #

Adds one or more flags to a message. Returns the message's key if successful, false otherwise.

flag:: String or Enumerable of flags


[View source]
def data #

Returns the message's data from disk. If the path doesn't exist, raises File::NotFoundError.


[View source]
def destroy #

Deletes the message path. Returns nil if the file was destroyed, false if the file was missing.


[View source]
def dir : String #

[View source]
def draft! #

Adds the "D" (draft) flag to the message. Returns the message's key if successful, false otherwise.


[View source]
def draft? #

Returns true if the message carries the "D" (draft) flag.


[View source]
def filename #

Returns the filename of the message


[View source]
def flagged! #

Adds the "F" (flagged) flag to the message. Returns the message's key if successful, false otherwise.


[View source]
def flagged? #

Returns true if the message carries the "F" (flagged) flag.


[View source]
def flags : Array(String) #

Returns an array of single letter flags applied to the message


[View source]
def flags=(flags) #

Sets the flags on a message. Returns the message's key if successful, false otherwise.

flags:: String or Enumerable of flags


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


[View source]
def info : String | Nil #

[View source]
def info=(info) #

Set info on a message. Returns the message's key if successful, false otherwise.


[View source]
def inspect(io : IO) : Nil #

Friendly inspect method


[View source]
def key #

Returns the key to identify the message


[View source]
def mtime #

Returns the message's mtime, or false if the file doesn't exist.


[View source]
def passed! #

Adds the "P" (passed) flag to the message. Returns the message's key if successful, false otherwise.


[View source]
def passed? #

Returns true if the message carries the "P" (passed) flag.


[View source]
def path #

Returns the full path to the message


[View source]
def process #

Move a message from new to cur, add info. Returns the message's key


[View source]
def remove_flag(flags) #

Removes flags from a message. Returns the message's key if successful, false otherwise.

flags:: String or Enumerable of flags


[View source]
def replied! #

Adds the "R" (replied) flag to the message. Returns the message's key if successful, false otherwise.


[View source]
def replied? #

Returns true if the message carries the "R" (replied) flag.


[View source]
def seen! #

Adds the "S" (seen) flag to the message. Returns the message's key if successful, false otherwise.


[View source]
def seen? #

Returns true if the message carries the "S" (seen) flag.


[View source]
def serializer #

Helper to get serializer.


[View source]
def trashed! #

Adds the "T" (trashed) flag to the message. Returns the message's key if successful, false otherwise.


[View source]
def trashed? #

Returns true if the message carries the "T" (trashed) flag.


[View source]
def unique_name : String #

[View source]
def utime(atime, mtime) #

Updates the modification and access time. Returns nil if successful, false if the file doesn't exist.


[View source]
def write(data) #

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


[View source]