From: Daniel Schierbeck Date: 2005-09-04T02:26:26+09:00 Subject: Re: [ANN] gmailer-0.0.8 released One thing that would be cool is a more advanced API. Something along the lines of this: Module GMailer # the main class. class Connection # returns the messages that match the filters # or all messages if no filter is provided def messages (filters = {}); end # returns all labels def labels; end # returns the label that has the name "name" # as a Label object def label (name); end # etc etc end # a list of messages. should be sortable and searchable. class MessageList; end # a single message class Message attr_reader :subject, :body, :to, :from, :date # applies a label to the message. # can take either a string or a Label object as argument def apply_label (label); end def remove_label; end def archive; end def unarchive; end def archived?; end def mark_read; end def mark_unread; end def read?; end def report_spam; end def report_not_spam; end def spam?; end def trash; end def untrash; end # etc etc end class Label # you get the picture end def connect (*args, &block) Connection.new(*args, &block) end end GMailer::connect(username, password) do |gmail| gmail.messages(:unread).each do |msg| puts "subject: " + msg.subject puts "from: " + msg.from end end