Class: WonderCroc::Folder

Inherits:
Object
  • Object
show all
Defined in:
lib/wondercroc/folder.rb

Overview

A folder is a folder that resides in a NewsGator location. It can contain subscriptions and other folders.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id) ⇒ Folder

Returns a new instance of Folder.

Raises:

  • (ArgumentException)


20
21
22
23
24
25
26
# File 'lib/wondercroc/folder.rb', line 20

def initialize name, id
  raise ArgumentException unless name
  @name = name
  @folder_id = id
  @unread_count = 0
  @subfolders = []
end

Instance Attribute Details

#folder_idObject

Returns the value of attribute folder_id.



17
18
19
# File 'lib/wondercroc/folder.rb', line 17

def folder_id
  @folder_id
end

#nameObject

Returns the value of attribute name.



17
18
19
# File 'lib/wondercroc/folder.rb', line 17

def name
  @name
end

#unread_countObject (readonly)

Returns the value of attribute unread_count.



18
19
20
# File 'lib/wondercroc/folder.rb', line 18

def unread_count
  @unread_count
end

Instance Method Details

#<<(subfolder) ⇒ Object



37
38
39
# File 'lib/wondercroc/folder.rb', line 37

def << subfolder
  @subfolders << subfolder
end

#find_by_id(id) ⇒ Object



45
46
47
48
# File 'lib/wondercroc/folder.rb', line 45

def find_by_id id
  return self if @folder_id == id
  @subfolders.each { |subfolder| return subfolder if subfolder.find_by_id id}
end

#merge(array) ⇒ Object



41
42
43
# File 'lib/wondercroc/folder.rb', line 41

def merge array
  @subfolders += array if array
end

#subfoldersObject



33
34
35
# File 'lib/wondercroc/folder.rb', line 33

def subfolders
  return @subfolders
end

#to_strObject



28
29
30
31
# File 'lib/wondercroc/folder.rb', line 28

def to_str
  return @name if @unread_count == 0
  return "#{@name} (#{@unread_count})"
end