Class: WonderCroc::Folder
- Inherits:
-
Object
- Object
- WonderCroc::Folder
- 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
-
#folder_id ⇒ Object
Returns the value of attribute folder_id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#unread_count ⇒ Object
readonly
Returns the value of attribute unread_count.
Instance Method Summary collapse
- #<<(subfolder) ⇒ Object
- #find_by_id(id) ⇒ Object
-
#initialize(name, id) ⇒ Folder
constructor
A new instance of Folder.
- #merge(array) ⇒ Object
- #subfolders ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(name, id) ⇒ Folder
Returns a new instance of Folder.
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_id ⇒ Object
Returns the value of attribute folder_id.
17 18 19 |
# File 'lib/wondercroc/folder.rb', line 17 def folder_id @folder_id end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/wondercroc/folder.rb', line 17 def name @name end |
#unread_count ⇒ Object (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 |
#subfolders ⇒ Object
33 34 35 |
# File 'lib/wondercroc/folder.rb', line 33 def subfolders return @subfolders end |
#to_str ⇒ Object
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 |