Class: Gmail::Label

Inherits:
APIResource show all
Includes:
Base::Create, Base::Delete, Base::Get, Base::List, Base::Update
Defined in:
lib/gmail/label.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::Update

#update, #update!

Methods included from Base::Get

included

Methods included from Base::Delete

#delete, included

Methods included from Base::Create

included

Methods included from Base::List

included

Methods inherited from APIResource

base_method, class_name

Methods inherited from GmailObject

#[], #[]=, #as_json, #detailed, #initialize, #inspect, #refresh, #to_hash, #to_json, #to_s, #values

Constructor Details

This class inherits a constructor from Gmail::GmailObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Gmail::GmailObject

Class Method Details

.boxesObject



17
18
19
# File 'lib/gmail/label.rb', line 17

def self.boxes
  @boxes ||= [:inbox, :sent, :trash, :important, :starred, :draft, :spam, :unread, :category_updates, :category_promotions, :category_social, :category_personal, :category_forums ]
end

Instance Method Details

#messages(filters = {}) ⇒ Object



27
28
29
30
31
# File 'lib/gmail/label.rb', line 27

def messages filters={}
  filters = {labelIds: [id]}.merge(filters)
  filters[:labelIds] = filters[:labelIds] | [id]
  Message.all(filters)
end

#saveObject



9
10
11
# File 'lib/gmail/label.rb', line 9

def save
  update(to_hash)
end

#save!Object



13
14
15
# File 'lib/gmail/label.rb', line 13

def save!
  update!(to_hash)
end

#threads(filters = {}) ⇒ Object



41
42
43
44
45
# File 'lib/gmail/label.rb', line 41

def threads filters={}
  filters = {labelIds: [id]}.merge(filters)
  filters[:labelIds] = filters[:labelIds] | [id]
  Thread.all(filters)
end

#unread_messagesObject



33
34
35
36
37
38
39
# File 'lib/gmail/label.rb', line 33

def unread_messages
  if messagesUnread == 0
    []
  else
    Message.all({labelIds: [id, "UNREAD"]})
  end
end

#unread_threadsObject



47
48
49
# File 'lib/gmail/label.rb', line 47

def unread_threads
  Thread.all({labelIds: [id, "UNREAD"]})
end