1 /* The Ruby interface to the notmuch mail library
3 * Copyright © 2010, 2011 Ali Polatel
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see https://www.gnu.org/licenses/ .
18 * Author: Ali Polatel <alip@exherbo.org>
24 * call-seq: MESSAGES.destroy! => nil
26 * Destroys the messages, freeing all resources allocated for it.
29 notmuch_rb_messages_destroy (VALUE self)
31 notmuch_rb_object_destroy (self, ¬much_rb_messages_type);
36 /* call-seq: MESSAGES.each {|item| block } => MESSAGES
38 * Calls +block+ once for each message in +self+, passing that element as a
42 notmuch_rb_messages_each (VALUE self)
44 notmuch_message_t *message;
45 notmuch_messages_t *messages;
47 Data_Get_Notmuch_Messages (self, messages);
49 for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) {
50 message = notmuch_messages_get (messages);
51 rb_yield (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message));
58 * call-seq: MESSAGES.tags => TAGS
60 * Collect tags from the messages
63 notmuch_rb_messages_collect_tags (VALUE self)
66 notmuch_messages_t *messages;
68 Data_Get_Notmuch_Messages (self, messages);
70 tags = notmuch_messages_collect_tags (messages);
72 rb_raise (notmuch_rb_eMemoryError, "Out of memory");
74 return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags);