class Gmail::Labels
Attributes
conn[R]
connection[R]
Public Class Methods
new(connection)
click to toggle source
# File lib/gmail/labels.rb, line 7 def initialize(connection) @connection = connection end
Public Instance Methods
all()
click to toggle source
Get list of all defined labels.
# File lib/gmail/labels.rb, line 12 def all (conn.list("", "%")+conn.list("[Gmail]/", "%")).inject([]) do |labels,label| label[:name].each_line {|l| labels << Net::IMAP.decode_utf7(l) } labels end end
create(label)
click to toggle source
Creates given label in your account.
# File lib/gmail/labels.rb, line 32 def create(label) !!conn.create(Net::IMAP.encode_utf7(label)) rescue false end
delete(label)
click to toggle source
Deletes given label from your account.
# File lib/gmail/labels.rb, line 39 def delete(label) !!conn.delete(Net::IMAP.encode_utf7(label)) rescue false end
Also aliased as: remove
each(*args, &block)
click to toggle source
# File lib/gmail/labels.rb, line 21 def each(*args, &block) all.each(*args, &block) end
exists?(label)
click to toggle source
Returns true
when given label defined.
# File lib/gmail/labels.rb, line 26 def exists?(label) all.include?(label) end
Also aliased as: exist?
inspect()
click to toggle source
# File lib/gmail/labels.rb, line 44 def inspect "#<Gmail::Labels#{'0x%04x' % (object_id << 1)}>" end