Sha256: 3f7d08947c7d7514207ea762a52dd40044e54c15fbacab5286ed54f651e7ff6a
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
module Gmail class Labels include Enumerable attr_reader :connection alias :conn :connection def initialize(connection) @connection = connection end # Get list of all defined labels. def all (conn.list("", "%")+conn.list("[Gmail]/", "%")).inject([]) do |labels,label| label[:name].each_line {|l| labels << l } labels end end alias :list :all alias :to_a :all def each(*args, &block) all.each(*args, &block) end # Returns +true+ when given label defined. def exists?(label) all.include?(label) end alias :exist? :exists? # Creates given label in your account. def create(label) !!conn.create(label) rescue false end alias :new :create alias :add :create # Deletes given label from your account. def delete(label) !!conn.delete(label) rescue false end alias :remove :delete def inspect "#<Gmail::Labels#{'0x%04x' % (object_id << 1)}>" end end # Labels end # Gmail
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gmail-0.3.4 | lib/gmail/labels.rb |
gmail-0.3.3 | lib/gmail/labels.rb |