Class: ContextIO::Folder
Instance Attribute Summary collapse
-
#account_id ⇒ String
readonly
The (Context.IO) ID of the account this folder belongs to, as a hexadecimal string.
-
#delim ⇒ String
readonly
The folder hierarchy delimiter.
-
#included_in_sync ⇒ true, false
readonly
Whether this folder is included when Context.IO syncs with the source.
-
#name ⇒ String
readonly
The full name of the folder.
-
#nb_messages ⇒ Integer
readonly
The number of messages in the folder.
-
#source_label ⇒ String
readonly
The label of the source this folder belongs to.
Class Method Summary collapse
-
.all(*args) ⇒ Array<ContextIO::Folder>
Get all folders for a given source and account.
-
.from_json(account_id, source_label, json) ⇒ ContextIO::Folder
private
Create a Folder with the JSON data from Context.IO.
Methods included from Request
#delete, #get, #post, #put, #request
Instance Attribute Details
#account_id ⇒ String (readonly)
Returns The (Context.IO) ID of the account this folder belongs to, as a hexadecimal string.
8 9 10 |
# File 'lib/context-io/folder.rb', line 8 def account_id @account_id end |
#delim ⇒ String (readonly)
Returns The folder hierarchy delimiter.
24 25 26 |
# File 'lib/context-io/folder.rb', line 24 def delim @delim end |
#included_in_sync ⇒ true, false (readonly)
Returns Whether this folder is included when Context.IO syncs with the source.
33 34 35 |
# File 'lib/context-io/folder.rb', line 33 def included_in_sync @included_in_sync end |
#name ⇒ String (readonly)
Returns The full name of the folder. This includes the name of parent folders.
17 18 19 |
# File 'lib/context-io/folder.rb', line 17 def name @name end |
#nb_messages ⇒ Integer (readonly)
Returns The number of messages in the folder.
28 29 30 |
# File 'lib/context-io/folder.rb', line 28 def @nb_messages end |
#source_label ⇒ String (readonly)
Returns The label of the source this folder belongs to.
12 13 14 |
# File 'lib/context-io/folder.rb', line 12 def source_label @source_label end |
Class Method Details
.all(account_id, source_label) ⇒ Array<ContextIO::Folder> .all(source) ⇒ Array<ContextIO::Folder>
Get all folders for a given source and account
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/context-io/folder.rb', line 49 def self.all(*args) if args.length == 1 account_id = args.first.account_id source_label = args.first.label elsif args.length == 2 account_id = args.first.to_s source_label = args.last.to_s else raise ArgumentError, "Expecting one or two arguments, got #{args.length}" end get("/2.0/accounts/#{account_id}/sources/#{source_label}/folders").map do |msg| Folder.from_json(account_id, source_label, msg) end end |
.from_json(account_id, source_label, json) ⇒ ContextIO::Folder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a Folder with the JSON data from Context.IO
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/context-io/folder.rb', line 76 def self.from_json(account_id, source_label, json) folder = new folder.instance_eval do @account_id = account_id @source_label = source_label @name = json['name'] @delim = json['delim'] @nb_messages = json['nb_messages'] @included_in_sync = json['included_in_sync'] end folder end |